[Cmake-commits] CMake branch, master, updated. v3.12.2-661-g7162630

Kitware Robot kwrobot at kitware.com
Tue Sep 18 11:25:04 EDT 2018


This is an automated email from 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  7162630beebeac105c1cd90270d26f29aa8c118f (commit)
       via  fc74fcc853641c3369670a15811b38c818d6b840 (commit)
       via  a8f628c0a456f74680bfdad0050f2614dbe50853 (commit)
       via  f4ff60a803170311f49511a60a381eef8b78c5dd (commit)
       via  7adf3aabd55dd80784727a229a37c394740db628 (commit)
       via  f9eac2ae4b986f74a97fe16fa19df94331a52b34 (commit)
       via  bef80e66231a0bd2feffab02fe8d1d8f55eb793c (commit)
       via  567fabe88e97c3e39503fd353b484648bcf1cbb2 (commit)
       via  53ad52d66d2056a4bf797d22ce1d3ee5395679a6 (commit)
       via  2a2f0ac231fe31052c6fabc2b2829653c5cea2fa (commit)
       via  329f6aeca5011e423a65ccede3177cd4f0ef1e21 (commit)
       via  ffb560adc98ee7c07d0e3cd50b28a38a4997cc8b (commit)
       via  b0b53921cef242acc91e6ab4dd495daff54191d6 (commit)
      from  6097d8dd3d6ea6e5a0a6012952b722d0719d39e9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7162630beebeac105c1cd90270d26f29aa8c118f
commit 7162630beebeac105c1cd90270d26f29aa8c118f
Merge: fc74fcc bef80e6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 18 15:22:33 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 18 11:22:41 2018 -0400

    Merge topic 'vs-ipo'
    
    bef80e6623 VS: Do not specify incremental linking if LTCG is enabled
    567fabe88e IPO: INTERPROCEDURAL_OPTIMIZATION (LTCG) for Visual Studio
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2363


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fc74fcc853641c3369670a15811b38c818d6b840
commit fc74fcc853641c3369670a15811b38c818d6b840
Merge: a8f628c 53ad52d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 18 15:18:52 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 18 11:18:57 2018 -0400

    Merge topic 'link-options'
    
    53ad52d66d LINK_OPTIONS: Add missing initialization actions
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2395


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a8f628c0a456f74680bfdad0050f2614dbe50853
commit a8f628c0a456f74680bfdad0050f2614dbe50853
Merge: 7adf3aa f4ff60a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 18 15:17:45 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 18 11:18:00 2018 -0400

    Merge topic 'getsafedef-stdstring'
    
    f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const&
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2350


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4ff60a803170311f49511a60a381eef8b78c5dd
commit f4ff60a803170311f49511a60a381eef8b78c5dd
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Wed Sep 5 06:41:28 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Sep 18 11:16:46 2018 -0400

    cmMakefile: Make GetSafeDefinition return std::string const&

diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 8863dc8..667a8ba 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -151,9 +151,9 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
       cmSystemTools::CollapseFullPath(this->Values[ct_BUILD]).c_str(),
       this->Quiet);
   } else {
-    const char* bdir =
+    std::string const& bdir =
       this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
-    if (bdir) {
+    if (!bdir.empty()) {
       this->CTest->SetCTestConfiguration(
         "BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(),
         this->Quiet);
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 2107d32..a3e135f 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -1725,7 +1725,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
     }
     const char* stagePath =
       this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
-    const char* installPrefix =
+    std::string const& installPrefix =
       this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
     cmSystemTools::ConvertToUnixSlashes(rootPath);
     std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath();
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 4716e14..6f1afd7 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -36,7 +36,7 @@ bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends)
   std::string srcLang = "CMAKE_DEPENDS_CHECK_";
   srcLang += this->Language;
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
-  const char* srcStr = mf->GetSafeDefinition(srcLang);
+  std::string const& srcStr = mf->GetSafeDefinition(srcLang);
   std::vector<std::string> pairs;
   cmSystemTools::ExpandListArgument(srcStr, pairs);
 
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 1c5040a..d440080 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -195,7 +195,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
                                cmGeneratorTarget* target,
                                const std::string& prop)
 {
-  const char* installDir =
+  std::string const& installDir =
     target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
   std::string const& topSourceDir =
     target->GetLocalGenerator()->GetSourceDirectory();
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index fbf6560..07a60de 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -666,7 +666,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
     pureFortran = true;
   }
 
-  std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
+  std::string const& compilerId = mf->GetSafeDefinition(compilerIdVar);
   std::string compiler = "gcc"; // default to gcc
   if (compilerId == "MSVC") {
     if (mf->IsDefinitionSet("MSVC10")) {
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index fe5c7bb..28106d1 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -599,7 +599,7 @@ std::string cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(
     compilerIdVar = "CMAKE_C_COMPILER_ID";
   }
 
-  std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
+  std::string const& compilerId = mf->GetSafeDefinition(compilerIdVar);
   std::string compiler = "gnu g++"; // default to g++
 
   // Since we need the compiler for parsing purposes only
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 1e51f09..54e33c5 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -580,10 +580,11 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
                                    cmGeneratorExpressionDAGChecker* /*unused*/,
                                    const std::string& lang) const
   {
-    const char* compilerId = context->LG->GetMakefile()->GetSafeDefinition(
-      "CMAKE_" + lang + "_COMPILER_ID");
+    std::string const& compilerId =
+      context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
+                                                    "_COMPILER_ID");
     if (parameters.empty()) {
-      return compilerId ? compilerId : "";
+      return compilerId;
     }
     static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
     if (!compilerIdValidator.find(*parameters.begin())) {
@@ -591,15 +592,16 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
                   "Expression syntax not recognized.");
       return std::string();
     }
-    if (!compilerId) {
+    if (compilerId.empty()) {
       return parameters.front().empty() ? "1" : "0";
     }
 
-    if (strcmp(parameters.begin()->c_str(), compilerId) == 0) {
+    if (strcmp(parameters.begin()->c_str(), compilerId.c_str()) == 0) {
       return "1";
     }
 
-    if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) {
+    if (cmsysString_strcasecmp(parameters.begin()->c_str(),
+                               compilerId.c_str()) == 0) {
       switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
         case cmPolicies::WARN: {
           std::ostringstream e;
@@ -676,11 +678,11 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
                                    cmGeneratorExpressionDAGChecker* /*unused*/,
                                    const std::string& lang) const
   {
-    const char* compilerVersion =
+    std::string const& compilerVersion =
       context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
                                                     "_COMPILER_VERSION");
     if (parameters.empty()) {
-      return compilerVersion ? compilerVersion : "";
+      return compilerVersion;
     }
 
     static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
@@ -689,13 +691,13 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
                   "Expression syntax not recognized.");
       return std::string();
     }
-    if (!compilerVersion) {
+    if (compilerVersion.empty()) {
       return parameters.front().empty() ? "1" : "0";
     }
 
     return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
                                          parameters.begin()->c_str(),
-                                         compilerVersion)
+                                         compilerVersion.c_str())
       ? "1"
       : "0";
   }
@@ -757,17 +759,17 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
     const GeneratorExpressionContent* /*content*/,
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
   {
-    const char* platformId =
+    std::string const& platformId =
       context->LG->GetMakefile()->GetSafeDefinition("CMAKE_SYSTEM_NAME");
     if (parameters.empty()) {
-      return platformId ? platformId : "";
+      return platformId;
     }
 
-    if (!platformId) {
+    if (platformId.empty()) {
       return parameters.front().empty() ? "1" : "0";
     }
 
-    if (strcmp(parameters.begin()->c_str(), platformId) == 0) {
+    if (*parameters.begin() == platformId) {
       return "1";
     }
     return "0";
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index e8e7b90..f563dd8 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -138,8 +138,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
                                      this->SourceEntries, true);
 
   this->DLLPlatform =
-    strcmp(this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"),
-           "") != 0;
+    !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
 
   this->PolicyMap = t->PolicyMap;
 }
@@ -3489,12 +3488,13 @@ void cmGeneratorTarget::GetFullNameInternal(
   }
 
   // if there is no prefix on the target use the cmake definition
+  std::string targetPrefix2, targetSuffix2;
   if (!targetPrefix && prefixVar) {
-    targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
+    targetPrefix2 = this->Makefile->GetSafeDefinition(prefixVar);
   }
   // if there is no suffix on the target use the cmake definition
   if (!targetSuffix && suffixVar) {
-    targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
+    targetSuffix2 = this->Makefile->GetSafeDefinition(suffixVar);
   }
 
   // frameworks have directory prefix but no suffix
@@ -3502,19 +3502,19 @@ void cmGeneratorTarget::GetFullNameInternal(
   if (this->IsFrameworkOnApple()) {
     fw_prefix = this->GetFrameworkDirectory(config, ContentLevel);
     fw_prefix += "/";
-    targetPrefix = fw_prefix.c_str();
-    targetSuffix = nullptr;
+    targetPrefix2 = fw_prefix;
+    targetSuffix2.clear();
   }
 
   if (this->IsCFBundleOnApple()) {
     fw_prefix = this->GetCFBundleDirectory(config, FullLevel);
     fw_prefix += "/";
-    targetPrefix = fw_prefix.c_str();
-    targetSuffix = nullptr;
+    targetPrefix2 = fw_prefix;
+    targetSuffix2.clear();
   }
 
   // Begin the final name with the prefix.
-  outPrefix = targetPrefix ? targetPrefix : "";
+  outPrefix = targetPrefix2;
 
   // Append the target name or property-specified name.
   outBase += this->GetOutputName(config, artifact);
@@ -3533,7 +3533,7 @@ void cmGeneratorTarget::GetFullNameInternal(
   }
 
   // Append the suffix.
-  outSuffix = targetSuffix ? targetSuffix : "";
+  outSuffix = targetSuffix2;
 }
 
 std::string cmGeneratorTarget::GetLinkerLanguage(
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index bf464d9..0d4d653 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -65,7 +65,7 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
                      "providing the name of the variable to get.");
       return false;
     }
-    std::string output = dir->GetSafeDefinition(*i);
+    std::string const& output = dir->GetSafeDefinition(*i);
     this->Makefile->AddDefinition(variable, output.c_str());
     return true;
   }
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 99135c8..f504b9f 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -828,8 +828,9 @@ void cmGlobalGenerator::EnableLanguage(
     std::string sharedLibFlagsVar = "CMAKE_SHARED_LIBRARY_";
     sharedLibFlagsVar += lang;
     sharedLibFlagsVar += "_FLAGS";
-    const char* sharedLibFlags = mf->GetSafeDefinition(sharedLibFlagsVar);
-    if (sharedLibFlags) {
+    std::string const& sharedLibFlags =
+      mf->GetSafeDefinition(sharedLibFlagsVar);
+    if (!sharedLibFlags.empty()) {
       this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags;
     }
 
@@ -1092,7 +1093,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
 {
   std::string extensionsVar = std::string("CMAKE_") + std::string(l) +
     std::string("_SOURCE_FILE_EXTENSIONS");
-  std::string exts = mf->GetSafeDefinition(extensionsVar);
+  const std::string& exts = mf->GetSafeDefinition(extensionsVar);
   std::vector<std::string> extensionList;
   cmSystemTools::ExpandListArgument(exts, extensionList);
   for (std::string const& i : extensionList) {
@@ -1112,7 +1113,7 @@ bool cmGlobalGenerator::GlobalSettingIsOn(std::string const& name) const
   return this->Makefiles[0]->IsOn(name);
 }
 
-const char* cmGlobalGenerator::GetSafeGlobalSetting(
+std::string cmGlobalGenerator::GetSafeGlobalSetting(
   std::string const& name) const
 {
   assert(!this->Makefiles.empty());
@@ -1593,7 +1594,7 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
     for (std::string const& li : langs) {
       std::string const standardIncludesVar =
         "CMAKE_" + li + "_STANDARD_INCLUDE_DIRECTORIES";
-      std::string const standardIncludesStr =
+      std::string const& standardIncludesStr =
         mf->GetSafeDefinition(standardIncludesVar);
       std::vector<std::string> standardIncludesVec;
       cmSystemTools::ExpandListArgument(standardIncludesStr,
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index c06ac52..8924772 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -230,7 +230,7 @@ public:
 
   const char* GetGlobalSetting(std::string const& name) const;
   bool GlobalSettingIsOn(std::string const& name) const;
-  const char* GetSafeGlobalSetting(std::string const& name) const;
+  std::string GetSafeGlobalSetting(std::string const& name) const;
 
   /** Add a file to the manifest of generated targets for a configuration.  */
   void AddToManifest(std::string const& f);
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 0c80910..4948c73 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -651,13 +651,13 @@ void cmGlobalNinjaGenerator::EnableLanguage(
     this->ResolveLanguageCompiler(l, mf, optional);
   }
 #ifdef _WIN32
-  if (strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") != 0 &&
-      strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "MSVC") != 0 &&
+  if ((mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID") != "MSVC") &&
+      (mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID") != "MSVC") &&
       (mf->IsOn("CMAKE_COMPILER_IS_MINGW") ||
-       strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "GNU") == 0 ||
-       strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "GNU") == 0 ||
-       strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "Clang") == 0 ||
-       strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "Clang") == 0)) {
+       (mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "GNU") ||
+       (mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "GNU") ||
+       (mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "Clang") ||
+       (mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "Clang"))) {
     this->UsingGCCOnWindows = true;
   }
 #endif
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index d7fe777..6e33cf7 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -5,7 +5,6 @@
 #include "cmsys/Glob.hxx"
 #include <sstream>
 #include <stddef.h>
-#include <string.h>
 #include <utility>
 
 #include "cmAlgorithms.h"
@@ -350,8 +349,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
 
   // Check whether this is a DLL platform.
   bool dll_platform =
-    strcmp(this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"),
-           "") != 0;
+    !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
 
   for (std::string const& tgt : targetList.GetVector()) {
 
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 4f8f2e7..7eb4ef4 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -683,7 +683,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
 
   std::string flagVar = "CMAKE_INCLUDE_FLAG_";
   flagVar += lang;
-  const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar);
+  std::string const& includeFlag = this->Makefile->GetSafeDefinition(flagVar);
   flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
   flagVar += lang;
   const char* sep = this->Makefile->GetDefinition(flagVar);
@@ -1824,9 +1824,9 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
     std::string flagsVar = "CMAKE_SHARED_LIBRARY_";
     flagsVar += lang;
     flagsVar += "_FLAGS";
-    const char* flags = this->Makefile->GetSafeDefinition(flagsVar);
+    std::string const& flags = this->Makefile->GetSafeDefinition(flagsVar);
 
-    if (flags && flags != originalFlags) {
+    if (!flags.empty() && flags != originalFlags) {
       switch (this->GetPolicyStatus(cmPolicies::CMP0018)) {
         case cmPolicies::WARN: {
           std::ostringstream e;
@@ -1859,7 +1859,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
                                                    std::string const& lang,
                                                    int targetType)
 {
-  const char* picFlags = nullptr;
+  std::string picFlags;
 
   if (targetType == cmStateEnums::EXECUTABLE) {
     std::string flagsVar = "CMAKE_";
@@ -1867,13 +1867,13 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
     flagsVar += "_COMPILE_OPTIONS_PIE";
     picFlags = this->Makefile->GetSafeDefinition(flagsVar);
   }
-  if (!picFlags) {
+  if (picFlags.empty()) {
     std::string flagsVar = "CMAKE_";
     flagsVar += lang;
     flagsVar += "_COMPILE_OPTIONS_PIC";
     picFlags = this->Makefile->GetSafeDefinition(flagsVar);
   }
-  if (picFlags) {
+  if (!picFlags.empty()) {
     std::vector<std::string> options;
     cmSystemTools::ExpandListArgument(picFlags, options);
     for (std::string const& o : options) {
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 690b827..272cc0e 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1422,7 +1422,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
   this->WriteDisclaimer(internalRuleFileStream);
 
   // for each language we need to scan, scan it
-  const char* langStr = mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
+  std::string const& langStr =
+    mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
   std::vector<std::string> langs;
   cmSystemTools::ExpandListArgument(langStr, langs);
   for (std::string const& lang : langs) {
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index c05b085..c03afdd 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1082,7 +1082,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
       // Use the NOINHERIT macro to avoid getting VS project default
       // libraries which may be set by the user to something bad.
       fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
-           << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
+           << this->Makefile->GetSafeDefinition(standardLibsVar);
       if (this->FortranProject) {
         this->Internal->OutputObjects(fout, target, configName, " ");
       }
@@ -1167,7 +1167,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
       // Use the NOINHERIT macro to avoid getting VS project default
       // libraries which may be set by the user to something bad.
       fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
-           << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
+           << this->Makefile->GetSafeDefinition(standardLibsVar);
       if (this->FortranProject) {
         this->Internal->OutputObjects(fout, target, configName, " ");
       }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index dce7bd0..26cc10d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2384,7 +2384,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
   return def != nullptr;
 }
 
-const char* cmMakefile::GetDefinition(const std::string& name) const
+const std::string* cmMakefile::GetDef(const std::string& name) const
 {
   const std::string* def = this->StateSnapshot.GetDefinition(name);
   if (!def) {
@@ -2410,16 +2410,26 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
     }
   }
 #endif
-  return (def ? def->c_str() : nullptr);
+  return def;
 }
 
-const char* cmMakefile::GetSafeDefinition(const std::string& def) const
+const char* cmMakefile::GetDefinition(const std::string& name) const
 {
-  const char* ret = this->GetDefinition(def);
-  if (!ret) {
-    return "";
+  const std::string* def = GetDef(name);
+  if (!def) {
+    return nullptr;
   }
-  return ret;
+  return def->c_str();
+}
+
+const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const
+{
+  static std::string const empty;
+  const std::string* def = GetDef(name);
+  if (!def) {
+    return empty;
+  }
+  return *def;
 }
 
 std::vector<std::string> cmMakefile::GetDefinitions() const
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 0ab4371..8c7eb31 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -422,7 +422,8 @@ public:
    * cache is then queried.
    */
   const char* GetDefinition(const std::string&) const;
-  const char* GetSafeDefinition(const std::string&) const;
+  const std::string* GetDef(const std::string&) const;
+  const std::string& GetSafeDefinition(const std::string&) const;
   std::string GetRequiredDefinition(const std::string& name) const;
   bool IsDefinitionSet(const std::string&) const;
   /**
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index ebcc501..7ac8d1b 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -10,7 +10,6 @@
 #include <map>
 #include <memory> // IWYU pragma: keep
 #include <sstream>
-#include <string.h>
 
 #include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
@@ -174,9 +173,8 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
 
 bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
 {
-  return strcmp(this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" +
-                                                       lang),
-                "msvc") == 0;
+  return (this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" +
+                                                 lang) == "msvc");
 }
 
 // TODO: Refactor with
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index ba50fb8..5caea7d 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -135,7 +135,7 @@ static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
                              cmPolicies::PolicyStatus* defaultSetting)
 {
   std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
-  std::string defaultValue = mf->GetSafeDefinition(defaultVar);
+  std::string const& defaultValue = mf->GetSafeDefinition(defaultVar);
   if (defaultValue == "NEW") {
     *defaultSetting = cmPolicies::NEW;
   } else if (defaultValue == "OLD") {
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 8bd985a..8a202a2 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1126,7 +1126,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
       }
     };
     auto MfDef = [makefile](const char* key) {
-      return std::string(makefile->GetSafeDefinition(key));
+      return makefile->GetSafeDefinition(key);
     };
 
     // Write
diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx
index c364700..2e6f90f 100644
--- a/Source/cmQtAutoGeneratorMocUic.cxx
+++ b/Source/cmQtAutoGeneratorMocUic.cxx
@@ -1204,7 +1204,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
       valueConf = makefile->GetDefinition(keyConf);
     }
     if (valueConf == nullptr) {
-      valueConf = makefile->GetSafeDefinition(key);
+      return makefile->GetSafeDefinition(key);
     }
     return std::string(valueConf);
   };
@@ -1226,7 +1226,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
   Base_.MultiConfig = InfoGetBool("AM_MULTI_CONFIG");
   {
     unsigned long num = Base_.NumThreads;
-    if (cmSystemTools::StringToULong(InfoGet("AM_PARALLEL"), &num)) {
+    if (cmSystemTools::StringToULong(InfoGet("AM_PARALLEL").c_str(), &num)) {
       num = std::max<unsigned long>(num, 1);
       num = std::min<unsigned long>(num, ParallelMax);
       Base_.NumThreads = static_cast<unsigned int>(num);
@@ -1264,7 +1264,8 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
   // - Qt environment
   {
     unsigned long qtv = Base_.QtVersionMajor;
-    if (cmSystemTools::StringToULong(InfoGet("AM_QT_VERSION_MAJOR"), &qtv)) {
+    if (cmSystemTools::StringToULong(InfoGet("AM_QT_VERSION_MAJOR").c_str(),
+                                     &qtv)) {
       Base_.QtVersionMajor = static_cast<unsigned int>(qtv);
     }
   }
diff --git a/Source/cmQtAutoGeneratorRcc.cxx b/Source/cmQtAutoGeneratorRcc.cxx
index 6caa0d8..65c6741 100644
--- a/Source/cmQtAutoGeneratorRcc.cxx
+++ b/Source/cmQtAutoGeneratorRcc.cxx
@@ -52,7 +52,7 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile)
       valueConf = makefile->GetDefinition(keyConf);
     }
     if (valueConf == nullptr) {
-      valueConf = makefile->GetSafeDefinition(key);
+      return makefile->GetSafeDefinition(key);
     }
     return std::string(valueConf);
   };
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index cfcb31a..703c552 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -190,13 +190,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
 
   // Check whether this is a DLL platform.
   this->DLLPlatform =
-    strcmp(this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"),
-           "") != 0;
+    !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
 
   // Check whether we are targeting an Android platform.
   this->IsAndroid =
-    strcmp(this->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME"),
-           "Android") == 0;
+    (this->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android");
 
   // Setup default property values.
   if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 53a2a59..9d9703c 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2699,11 +2699,9 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
   Options& rcOptions = *pOptions;
 
   std::string CONFIG = cmSystemTools::UpperCase(configName);
-  std::string rcConfigFlagsVar = std::string("CMAKE_RC_FLAGS_") + CONFIG;
-  std::string flags =
-    std::string(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS")) +
-    std::string(" ") +
-    std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
+  std::string rcConfigFlagsVar = "CMAKE_RC_FLAGS_" + CONFIG;
+  std::string flags = this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS") +
+    " " + this->Makefile->GetSafeDefinition(rcConfigFlagsVar);
 
   rcOptions.Parse(flags);
 
@@ -2757,10 +2755,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
   // Get compile flags for CUDA in this directory.
   std::string CONFIG = cmSystemTools::UpperCase(configName);
   std::string configFlagsVar = std::string("CMAKE_CUDA_FLAGS_") + CONFIG;
-  std::string flags =
-    std::string(this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS")) +
-    std::string(" ") +
-    std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
+  std::string flags = this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS") +
+    " " + this->Makefile->GetSafeDefinition(configFlagsVar);
   this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, "CUDA",
                                           configName);
 
@@ -2971,9 +2967,8 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
   std::string CONFIG = cmSystemTools::UpperCase(configName);
   std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG;
   std::string flags =
-    std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS")) +
-    std::string(" ") +
-    std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
+    this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS") + " " +
+    this->Makefile->GetSafeDefinition(configFlagsVar);
 
   masmOptions.Parse(flags);
 
@@ -3024,14 +3019,11 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
   Options& nasmOptions = *pOptions;
 
   std::string CONFIG = cmSystemTools::UpperCase(configName);
-  std::string configFlagsVar = std::string("CMAKE_ASM_NASM_FLAGS_") + CONFIG;
+  std::string configFlagsVar = "CMAKE_ASM_NASM_FLAGS_" + CONFIG;
   std::string flags =
-    std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_FLAGS")) +
-    std::string(" -f") +
-    std::string(
-      this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT")) +
-    std::string(" ") +
-    std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
+    this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_FLAGS") + " -f" +
+    this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT") + " " +
+    this->Makefile->GetSafeDefinition(configFlagsVar);
   nasmOptions.Parse(flags);
 
   // Get includes for this target

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7adf3aabd55dd80784727a229a37c394740db628
commit 7adf3aabd55dd80784727a229a37c394740db628
Merge: f9eac2a 2a2f0ac
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 18 15:16:03 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 18 11:16:09 2018 -0400

    Merge topic 'if-version-docs'
    
    2a2f0ac231 Help: Clarify handling of non-integer components in if() version tests
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2393


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9eac2ae4b986f74a97fe16fa19df94331a52b34
commit f9eac2ae4b986f74a97fe16fa19df94331a52b34
Merge: 6097d8d 329f6ae
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 18 15:15:07 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 18 11:15:13 2018 -0400

    Merge topic 'FindPython-updates'
    
    329f6aeca5 FindPython*: Windows: add facility to select lookup order for registry.
    ffb560adc9 FindPython*: MacOS: Fix erroneous handling of Frameworks.
    b0b53921ce FindPython: clean-up lookup names strategy
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2369


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bef80e66231a0bd2feffab02fe8d1d8f55eb793c
commit bef80e66231a0bd2feffab02fe8d1d8f55eb793c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Sep 12 13:45:05 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Sep 17 10:53:27 2018 -0400

    VS: Do not specify incremental linking if LTCG is enabled
    
    Otherwise the linker may warn:
    
        LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index c0b0435..2a54cfc 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2374,9 +2374,11 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
   Options& linkOptions = *(this->LinkOptions[configName]);
   const std::string cond = this->CalcCondition(configName);
 
-  const char* incremental = linkOptions.GetFlag("LinkIncremental");
-  e1.WritePlatformConfigTag("LinkIncremental", cond,
-                            (incremental ? incremental : "true"));
+  if (this->IPOEnabledConfigurations.count(configName) == 0) {
+    const char* incremental = linkOptions.GetFlag("LinkIncremental");
+    e1.WritePlatformConfigTag("LinkIncremental", cond,
+                              (incremental ? incremental : "true"));
+  }
   linkOptions.RemoveFlag("LinkIncremental");
 
   const char* manifest = linkOptions.GetFlag("GenerateManifest");

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=567fabe88e97c3e39503fd353b484648bcf1cbb2
commit 567fabe88e97c3e39503fd353b484648bcf1cbb2
Author:     Niels Dekker <N.Dekker at lumc.nl>
AuthorDate: Sun Sep 9 23:04:59 2018 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Sep 17 10:53:10 2018 -0400

    IPO: INTERPROCEDURAL_OPTIMIZATION (LTCG) for Visual Studio
    
    Add IPO support for Visual Studio (which is referred to by VS as
    "Link Time Code Generation" and "Whole Program Optimization"), for
    VS version >= 10.  This allows CMake/VS users to enable IPO by setting
    property `INTERPROCEDURAL_OPTIMIZATION`.
    
    Fixes: #16748

diff --git a/Help/release/dev/vs-ipo.rst b/Help/release/dev/vs-ipo.rst
new file mode 100644
index 0000000..a31601f
--- /dev/null
+++ b/Help/release/dev/vs-ipo.rst
@@ -0,0 +1,6 @@
+vs-ipo
+------
+
+* The :ref:`Visual Studio Generators` for VS 2010 and above learned to
+  support the :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION` target property
+  and supporting :module:`CheckIPOSupported` module.
diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake
index 3344834..ad8852c 100644
--- a/Modules/CheckIPOSupported.cmake
+++ b/Modules/CheckIPOSupported.cmake
@@ -226,7 +226,7 @@ function(check_ipo_supported)
     endif()
   endforeach()
 
-  if(CMAKE_GENERATOR MATCHES "^Visual Studio ")
+  if(CMAKE_GENERATOR MATCHES "^Visual Studio 9 ")
     _ipo_not_supported("CMake doesn't support IPO for current generator")
     return()
   endif()
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 6eb597c..63e6903 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -111,6 +111,8 @@ public:
 
   bool FindMakeProgram(cmMakefile* mf) override;
 
+  bool IsIPOSupported() const override { return true; }
+
   static std::string GetInstalledNsightTegraVersion();
 
   cmIDEFlagTable const* GetClFlagTable() const;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9e74335..c0b0435 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1122,6 +1122,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
       this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
     e1.Element("WindowsAppContainer", "true");
   }
+  if (this->IPOEnabledConfigurations.count(config) > 0) {
+    e1.Element("WholeProgramOptimization", "true");
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
@@ -2485,8 +2488,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
     clOptions.AddFlag("CompileAs", "CompileAsCpp");
   }
 
-  // Check IPO related warning/error.
-  this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName);
+  // Put the IPO enabled configurations into a set.
+  if (this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName)) {
+    this->IPOEnabledConfigurations.insert(configName);
+  }
 
   // Get preprocessor definitions for this directory.
   std::string defineFlags = this->Makefile->GetDefineFlags();
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 15e47b4..829d2bf 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -204,6 +204,7 @@ private:
   bool NsightTegra;
   unsigned int NsightTegraVersion[4];
   bool TargetCompileAsWinRT;
+  std::set<std::string> IPOEnabledConfigurations;
   cmGlobalVisualStudio10Generator* const GlobalGenerator;
   cmLocalVisualStudio10Generator* const LocalGenerator;
   std::set<std::string> CSharpCustomCommandNames;
diff --git a/Tests/RunCMake/CMP0069/RunCMakeTest.cmake b/Tests/RunCMake/CMP0069/RunCMakeTest.cmake
index f44f840..456e6a6 100644
--- a/Tests/RunCMake/CMP0069/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0069/RunCMakeTest.cmake
@@ -5,6 +5,6 @@ run_cmake(CMP0069-NEW-cmake)
 run_cmake(CMP0069-NEW-compiler)
 run_cmake(CMP0069-WARN)
 
-if(RunCMake_GENERATOR MATCHES "^Visual Studio ")
+if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
   run_cmake(CMP0069-NEW-generator)
 endif()
diff --git a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
index e145569..b7d524c 100644
--- a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
@@ -8,6 +8,6 @@ run_cmake(not-supported-by-compiler)
 run_cmake(save-to-result)
 run_cmake(cmp0069-is-old)
 
-if(RunCMake_GENERATOR MATCHES "^Visual Studio ")
+if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
   run_cmake(not-supported-by-generator)
 endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=53ad52d66d2056a4bf797d22ce1d3ee5395679a6
commit 53ad52d66d2056a4bf797d22ce1d3ee5395679a6
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Mon Sep 17 16:42:37 2018 +0200
Commit:     Marc Chevrier <marc.chevrier at gmail.com>
CommitDate: Mon Sep 17 16:42:37 2018 +0200

    LINK_OPTIONS: Add missing initialization actions

diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index c8b8653..c6667f6 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -659,6 +659,7 @@ cmStateSnapshot cmState::CreateBaseSnapshot()
   pos->IncludeDirectoryPosition = 0;
   pos->CompileDefinitionsPosition = 0;
   pos->CompileOptionsPosition = 0;
+  pos->LinkOptionsPosition = 0;
   pos->BuildSystemDirectory->DirectoryEnd = pos;
   pos->Policies = this->PolicyStack.Root();
   pos->PolicyRoot = this->PolicyStack.Root();
@@ -810,6 +811,8 @@ cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot)
     prevPos->BuildSystemDirectory->CompileDefinitions.size();
   prevPos->CompileOptionsPosition =
     prevPos->BuildSystemDirectory->CompileOptions.size();
+  prevPos->LinkOptionsPosition =
+    prevPos->BuildSystemDirectory->LinkOptions.size();
   prevPos->BuildSystemDirectory->DirectoryEnd = prevPos;
 
   if (!pos->Keep && this->SnapshotData.IsLast(pos)) {

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2a2f0ac231fe31052c6fabc2b2829653c5cea2fa
commit 2a2f0ac231fe31052c6fabc2b2829653c5cea2fa
Author:     Craig Scott <craig.scott at crascit.com>
AuthorDate: Sun Sep 16 11:15:47 2018 +0800
Commit:     Craig Scott <craig.scott at crascit.com>
CommitDate: Mon Sep 17 18:12:08 2018 +0800

    Help: Clarify handling of non-integer components in if() version tests

diff --git a/Help/command/if.rst b/Help/command/if.rst
index f04f233..5294ce8 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -148,23 +148,33 @@ Possible expressions are:
 
 ``if(<variable|string> VERSION_LESS <variable|string>)``
  Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
 
 ``if(<variable|string> VERSION_GREATER <variable|string>)``
  Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
 
 ``if(<variable|string> VERSION_EQUAL <variable|string>)``
  Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
 
 ``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
  Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
 
 ``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
  Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
 
 ``if(<variable|string> IN_LIST <variable>)``
  True if the given element is contained in the named list variable.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=329f6aeca5011e423a65ccede3177cd4f0ef1e21
commit 329f6aeca5011e423a65ccede3177cd4f0ef1e21
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Tue Sep 11 10:48:08 2018 +0200
Commit:     Marc Chevrier <marc.chevrier at gmail.com>
CommitDate: Wed Sep 12 10:04:05 2018 +0200

    FindPython*: Windows: add facility to select lookup order for registry.
    
    Fixes: #18302

diff --git a/Help/release/dev/FindPython-lookup-strategy.rst b/Help/release/dev/FindPython-lookup-strategy.rst
new file mode 100644
index 0000000..f6d6db5
--- /dev/null
+++ b/Help/release/dev/FindPython-lookup-strategy.rst
@@ -0,0 +1,6 @@
+FindPython-lookup-strategy
+--------------------------
+
+* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
+  gain capability to control order of resource lookup on macOS (Framework) and
+  Windows (Registry).
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index b8657b4..0bf0b4f 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -116,6 +116,17 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``Python_FIND_REGISTRY``
+  On Windows the ``Python_FIND_REGISTRY`` variable determine the order
+  of preference between registry and environment variables.
+  the ``Python_FIND_REGISTRY`` variable can be set to empty or one of the
+  following:
+
+  * ``FIRST``: Try to use registry before environment variables.
+    This is the default.
+  * ``LAST``: Try to use registry after environment variables.
+  * ``NEVER``: Never try to use registry.
+
 ``CMAKE_FIND_FRAMEWORK``
   On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
   preference between Apple-style and unix-style package components.
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 137c769..1834591 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -100,7 +100,7 @@ function (_PYTHON_VALIDATE_INTERPRETER)
       return()
     endif()
   else()
-    if (python_name STREQUAL "python${CMAKE_EXECUTABLE_SUFFIX}")
+    if (NOT python_name STREQUAL "python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}${CMAKE_EXECUTABLE_SUFFIX}")
       # executable found do not have version in name
       # ensure major version is OK
       execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
@@ -135,6 +135,33 @@ function (_PYTHON_VALIDATE_INTERPRETER)
 endfunction()
 
 
+function (_PYTHON_VALIDATE_COMPILER expected_version)
+  if (NOT ${_PYTHON_PREFIX}_COMPILER)
+    return()
+  endif()
+
+  # retrieve python environment version from compiler
+  set (working_dir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir")
+  file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))\n")
+  execute_process (COMMAND "${${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${working_dir}/version.py"
+                   WORKING_DIRECTORY "${working_dir}"
+                   OUTPUT_QUIET
+                   ERROR_QUIET
+                   OUTPUT_STRIP_TRAILING_WHITESPACE)
+  execute_process (COMMAND "${working_dir}/version"
+                   WORKING_DIRECTORY "${working_dir}"
+                   RESULT_VARIABLE result
+                   OUTPUT_VARIABLE version
+                   ERROR_QUIET)
+  file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}")
+
+  if (result OR NOT version EQUAL expected_version)
+    # Compiler not usable or has wrong major version
+    set (${_PYTHON_PREFIX}_COMPILER ${_PYTHON_PREFIX}_COMPILER-NOTFOUND CACHE INTERNAL "" FORCE)
+  endif()
+endfunction()
+
+
 function (_PYTHON_FIND_RUNTIME_LIBRARY _PYTHON_LIB)
   string (REPLACE "_RUNTIME" "" _PYTHON_LIB "${_PYTHON_LIB}")
   # look at runtime part on systems supporting it
@@ -223,6 +250,7 @@ else()
   # architecture unknown, search for natural interpreter
   set (_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES ipy)
 endif()
+set (_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES net45 net40)
 
 # Apple frameworks handling
 _python_find_frameworks ()
@@ -252,6 +280,18 @@ endif()
 # To avoid framework lookup
 set (CMAKE_FIND_FRAMEWORK "NEVER")
 
+# Windows Registry handling
+if (DEFINED ${_PYTHON_PREFIX}_FIND_REGISTRY)
+  if (NOT ${_PYTHON_PREFIX}_FIND_REGISTRY MATCHES "^(FIRST|LAST|NEVER)$")
+    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_REGISTRY}: invalid value for '${_PYTHON_PREFIX}_FIND_REGISTRY'. 'FIRST', 'LAST' or 'NEVER' expected.")
+    set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST")
+  else()
+    set (_${_PYTHON_PREFIX}_FIND_REGISTRY ${${_PYTHON_PREFIX}_FIND_REGISTRY})
+  endif()
+else()
+  set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST")
+endif()
+
 
 unset (_${_PYTHON_PREFIX}_REQUIRED_VARS)
 unset (_${_PYTHON_PREFIX}_CACHED_VARS)
@@ -286,18 +326,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
                     NO_CMAKE_SYSTEM_PATH)
     endif()
 
-    # try using HINTS
-    find_program (${_PYTHON_PREFIX}_EXECUTABLE
-                  NAMES python${_${_PYTHON_PREFIX}_VERSION}
-                        python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
-                  NAMES_PER_DIR
-                  HINTS ${_${_PYTHON_PREFIX}_HINTS}
-                  PATH_SUFFIXES bin
-                  NO_SYSTEM_ENVIRONMENT_PATH
-                  NO_CMAKE_SYSTEM_PATH)
-
-    # try using registry
-    if (WIN32)
+    # Windows registry
+    if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
       find_program (${_PYTHON_PREFIX}_EXECUTABLE
                     NAMES python${_${_PYTHON_PREFIX}_VERSION}
                           python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
@@ -312,15 +342,33 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                    PATH_SUFFIXES bin
+                    PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
                     NO_SYSTEM_ENVIRONMENT_PATH
                     NO_CMAKE_SYSTEM_PATH)
     endif()
 
-    # try in standard paths
+    # try using HINTS
     find_program (${_PYTHON_PREFIX}_EXECUTABLE
                   NAMES python${_${_PYTHON_PREFIX}_VERSION}
-                  NAMES_PER_DIR)
+                        python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                        python
+                        ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+                  NAMES_PER_DIR
+                  HINTS ${_${_PYTHON_PREFIX}_HINTS}
+                  PATH_SUFFIXES bin
+                  NO_SYSTEM_ENVIRONMENT_PATH
+                  NO_CMAKE_SYSTEM_PATH)
+    # try using standard paths.
+    # NAMES_PER_DIR is not defined on purpose to have a chance to find
+    # expected version.
+    # For example, typical systems have 'python' for version 2.* and 'python3'
+    # for version 3.*. So looking for names per dir will find, potentially,
+    # systematically 'python' (i.e. version 2) even if version 3 is searched.
+    find_program (${_PYTHON_PREFIX}_EXECUTABLE
+                  NAMES python${_${_PYTHON_PREFIX}_VERSION}
+                        python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                        python
+                        ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
 
     # Apple frameworks handling
     if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
@@ -333,24 +381,52 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
                     NO_DEFAULT_PATH)
     endif()
 
+    # Windows registry
+    if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+      find_program (${_PYTHON_PREFIX}_EXECUTABLE
+                    NAMES python${_${_PYTHON_PREFIX}_VERSION}
+                          python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                          python
+                          ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+                    NAMES_PER_DIR
+                    PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
+                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                    PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+                    NO_DEFAULT_PATH)
+    endif()
+
     _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION})
     if (${_PYTHON_PREFIX}_EXECUTABLE)
       break()
     endif()
   endforeach()
 
-  # try more generic names. NAMES_PER_DIR is not specified on purpose to have a
-  # chance to find expected version.
-  # For example, typical systems have 'python' for version 2.* and 'python3'
-  # for version 3.*. So looking for names per dir will find, potentially,
-  # systematically 'python' (i.e. version 2) even if version 3 is searched.
   if (NOT ${_PYTHON_PREFIX}_EXECUTABLE)
+    # No specific version found. Retry with generic names
+    # try using HINTS
     find_program (${_PYTHON_PREFIX}_EXECUTABLE
                   NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
                         python
                         ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
                   HINTS ${_${_PYTHON_PREFIX}_HINTS}
-                  PATH_SUFFIXES bin)
+                  PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+                  NO_SYSTEM_ENVIRONMENT_PATH
+                  NO_CMAKE_SYSTEM_PATH)
+    # try using standard paths.
+    # NAMES_PER_DIR is not defined on purpose to have a chance to find
+    # expected version.
+    # For example, typical systems have 'python' for version 2.* and 'python3'
+    # for version 3.*. So looking for names per dir will find, potentially,
+    # systematically 'python' (i.e. version 2) even if version 3 is searched.
+    find_program (${_PYTHON_PREFIX}_EXECUTABLE
+                  NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                        python
+                        ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
 
     _python_validate_interpreter ()
   endif()
@@ -451,19 +527,42 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
 
   # try using root dir and registry
   foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+    if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+      find_program (${_PYTHON_PREFIX}_COMPILER
+                    NAMES ipyc
+                    HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+                    PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                    PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+                    NO_SYSTEM_ENVIRONMENT_PATH
+                    NO_CMAKE_SYSTEM_PATH)
+    endif()
+
     find_program (${_PYTHON_PREFIX}_COMPILER
                   NAMES ipyc
                   HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
-                  PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                  PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
                   NO_SYSTEM_ENVIRONMENT_PATH
                   NO_CMAKE_SYSTEM_PATH)
+
+    if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+      find_program (${_PYTHON_PREFIX}_COMPILER
+                    NAMES ipyc
+                    PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                    PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+                    NO_DEFAULT_PATH)
+    endif()
+
+    _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION})
     if (${_PYTHON_PREFIX}_COMPILER)
       break()
     endif()
   endforeach()
-  # try in standard paths
+
+  # no specific version found, re-try in standard paths
   find_program (${_PYTHON_PREFIX}_COMPILER
-                NAMES ipyc)
+                NAMES ipyc
+                HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+                PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES})
 
   if (${_PYTHON_PREFIX}_COMPILER)
     # retrieve python environment version from compiler
@@ -664,6 +763,12 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
 
       _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
 
+      set (_${_PYTHON_PREFIX}_REGISTRY_PATHS
+        [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+        [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+        [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath])
+
       if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
         find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
                       NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}
@@ -685,7 +790,27 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                       NO_CMAKE_SYSTEM_PATH)
       endif()
 
-      # search first in known locations
+      if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+        find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
+                      NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}
+                            python${_${_PYTHON_PREFIX}_VERSION}mu
+                            python${_${_PYTHON_PREFIX}_VERSION}m
+                            python${_${_PYTHON_PREFIX}_VERSION}u
+                            python${_${_PYTHON_PREFIX}_VERSION}
+                      NAMES_PER_DIR
+                      HINTS ${_${_PYTHON_PREFIX}_HINTS}
+                      PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+                      PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}u
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config
+                      NO_SYSTEM_ENVIRONMENT_PATH
+                      NO_CMAKE_SYSTEM_PATH)
+      endif()
+
+      # search in HINTS locations
       find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
                     NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}
                           python${_${_PYTHON_PREFIX}_VERSION}mu
@@ -694,10 +819,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                           python${_${_PYTHON_PREFIX}_VERSION}
                     NAMES_PER_DIR
                     HINTS ${_${_PYTHON_PREFIX}_HINTS}
-                    PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
-                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                          [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                     PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs
                                   lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu
                                   lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m
@@ -713,6 +834,12 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
         unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
       endif()
 
+      if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+        set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS})
+      else()
+        unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS)
+      endif()
+
       # search in all default paths
       find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
                     NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}
@@ -722,6 +849,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                           python${_${_PYTHON_PREFIX}_VERSION}
                     NAMES_PER_DIR
                     PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+                          ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
                     PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs
                                   lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu
                                   lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m
@@ -739,10 +867,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                                             python${_${_PYTHON_PREFIX}_VERSION}
                                       NAMES_PER_DIR
                                       HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS}
-                                      PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                                            [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
-                                            [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                                            [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                                       PATH_SUFFIXES bin)
       endif()
 
@@ -752,27 +876,28 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
           # use library location as a hint
           get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
           find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG
-                      NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d
-                      NAMES_PER_DIR
-                      HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS}
-                      NO_DEFAULT_PATH)
-        else()
-          # search first in known locations
-          find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG
                         NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d
                         NAMES_PER_DIR
-                        HINTS ${_${_PYTHON_PREFIX}_HINTS}
-                        PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                              [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
-                              [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                              [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
-                        PATH_SUFFIXES lib libs
-                        NO_SYSTEM_ENVIRONMENT_PATH
-                        NO_CMAKE_SYSTEM_PATH)
+                        HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS}
+                        NO_DEFAULT_PATH)
+        else()
+          # search first in known locations
+          if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+            find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG
+                          NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d
+                          NAMES_PER_DIR
+                          HINTS ${_${_PYTHON_PREFIX}_HINTS}
+                          PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+                          PATH_SUFFIXES lib libs
+                          NO_SYSTEM_ENVIRONMENT_PATH
+                          NO_CMAKE_SYSTEM_PATH)
+          endif()
           # search in all default paths
           find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG
                         NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d
                         NAMES_PER_DIR
+                        HINTS ${_${_PYTHON_PREFIX}_HINTS}
+                        PATHS ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
                         PATH_SUFFIXES lib libs)
         endif()
         if (${_PYTHON_PREFIX}_LIBRARY_DEBUG)
@@ -781,10 +906,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                                         NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}_d
                                         NAMES_PER_DIR
                                         HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS}
-                                        PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                                              [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
-                                              [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                                              [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                                         PATH_SUFFIXES bin)
         endif()
       endif()
@@ -792,6 +913,21 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
       # Don't search for include dir until library location is known
       if (${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
         unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS)
+
+        if (${_PYTHON_PREFIX}_EXECUTABLE)
+          # pick up include directory from configuration
+          execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
+                                   "import sys; import sysconfig; sys.stdout.write(sysconfig.get_path('include'))"
+                           RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+                           OUTPUT_VARIABLE _${_PYTHON_PREFIX}_PATH
+                           ERROR_QUIET
+                           OUTPUT_STRIP_TRAILING_WHITESPACE)
+           if (NOT _${_PYTHON_PREFIX}_RESULT)
+             file (TO_CMAKE_PATH "${_${_PYTHON_PREFIX}_PATH}" _${_PYTHON_PREFIX}_PATH)
+             list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PATH}")
+           endif()
+        endif()
+
         foreach (_${_PYTHON_PREFIX}_LIB IN ITEMS ${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
           if (${_${_PYTHON_PREFIX}_LIB})
             # Use the library's install prefix as a hint
@@ -826,18 +962,26 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                      NO_SYSTEM_ENVIRONMENT_PATH
                      NO_CMAKE_SYSTEM_PATH)
         endif()
-        if (NOT _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
-          unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+
+        if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+          find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
+                     NAMES Python.h
+                     HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
+                     PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+                     PATH_SUFFIXES include/python${_${_PYTHON_PREFIX}_VERSION}mu
+                                   include/python${_${_PYTHON_PREFIX}_VERSION}m
+                                   include/python${_${_PYTHON_PREFIX}_VERSION}u
+                                   include/python${_${_PYTHON_PREFIX}_VERSION}
+                                   include
+                     NO_SYSTEM_ENVIRONMENT_PATH
+                     NO_CMAKE_SYSTEM_PATH)
         endif()
 
         find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
                    NAMES Python.h
                    HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
-                   PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
-                         [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                         [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
-                         [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
-                         [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+                   PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+                         ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
                    PATH_SUFFIXES include/python${_${_PYTHON_PREFIX}_VERSION}mu
                                  include/python${_${_PYTHON_PREFIX}_VERSION}m
                                  include/python${_${_PYTHON_PREFIX}_VERSION}u
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index 78ed29a..2735a25 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -117,8 +117,19 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``Python2_FIND_REGISTRY``
+  On Windows the ``Python2_FIND_REGISTRY`` variable determine the order
+  of preference between registry and environment variables.
+  the ``Python2_FIND_REGISTRY`` variable can be set to empty or one of the
+  following:
+
+  * ``FIRST``: Try to use registry before environment variables.
+    This is the default.
+  * ``LAST``: Try to use registry after environment variables.
+  * ``NEVER``: Never try to use registry.
+
 ``CMAKE_FIND_FRAMEWORK``
-  On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
+  On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
   preference between Apple-style and unix-style package components.
 
   .. note::
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index 48054a9..ed7e1a3 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -117,6 +117,17 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``Python3_FIND_REGISTRY``
+  On Windows the ``Python3_FIND_REGISTRY`` variable determine the order
+  of preference between registry and environment variables.
+  the ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the
+  following:
+
+  * ``FIRST``: Try to use registry before environment variables.
+    This is the default.
+  * ``LAST``: Try to use registry after environment variables.
+  * ``NEVER``: Never try to use registry.
+
 ``CMAKE_FIND_FRAMEWORK``
   On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
   preference between Apple-style and unix-style package components.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffb560adc98ee7c07d0e3cd50b28a38a4997cc8b
commit ffb560adc98ee7c07d0e3cd50b28a38a4997cc8b
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Thu Aug 2 16:50:40 2018 +0200
Commit:     Marc Chevrier <marc.chevrier at gmail.com>
CommitDate: Wed Sep 12 10:04:04 2018 +0200

    FindPython*: MacOS: Fix erroneous handling of Frameworks.
    
    Fixes: #18204

diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index 8139e53..b8657b4 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -116,6 +116,14 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``CMAKE_FIND_FRAMEWORK``
+  On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
+  preference between Apple-style and unix-style package components.
+
+  .. note::
+
+    Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+
 Commands
 ^^^^^^^^
 
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 9144ba4..137c769 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -44,9 +44,28 @@ macro (_PYTHON_DISPLAY_FAILURE _PYTHON_MSG)
 endmacro()
 
 
+macro (_PYTHON_FIND_FRAMEWORKS)
+  set (${_PYTHON_PREFIX}_FRAMEWORKS)
+  if (APPLE)
+    set (_pff_frameworks ${CMAKE_FRAMEWORK_PATH}
+                    $ENV{CMAKE_FRAMEWORK_PATH}
+                    ~/Library/Frameworks
+                    /usr/local/Frameworks
+                    ${CMAKE_SYSTEM_FRAMEWORK_PATH})
+    list (REMOVE_DUPLICATES _pff_frameworks)
+    foreach (_pff_framework IN LISTS _pff_frameworks)
+      if (EXISTS ${_pff_framework}/Python.framework)
+        list (APPEND ${_PYTHON_PREFIX}_FRAMEWORKS ${_pff_framework}/Python.framework)
+      endif()
+    endforeach()
+    unset (_pff_frameworks)
+    unset (_pff_framework)
+  endif()
+endmacro()
+
 function (_PYTHON_GET_FRAMEWORKS _PYTHON_PGF_FRAMEWORK_PATHS _PYTHON_VERSION)
   set (_PYTHON_FRAMEWORK_PATHS)
-  foreach (_PYTHON_FRAMEWORK IN LISTS Python_FRAMEWORKS)
+  foreach (_PYTHON_FRAMEWORK IN LISTS ${_PYTHON_PREFIX}_FRAMEWORKS)
     list (APPEND _PYTHON_FRAMEWORK_PATHS
           "${_PYTHON_FRAMEWORK}/Versions/${_PYTHON_VERSION}")
   endforeach()
@@ -59,20 +78,43 @@ function (_PYTHON_VALIDATE_INTERPRETER)
     return()
   endif()
 
-  if (${_PYTHON_PREFIX}_EXECUTABLE MATCHES "python${CMAKE_EXECUTABLE_SUFFIX}$")
-    # executable found do not have version in name
-    # ensure major version is OK
+  if (ARGC EQUAL 1)
+    set (expected_version ${ARGV0})
+  else()
+    unset (expected_version)
+  endif()
+
+  get_filename_component (python_name "${${_PYTHON_PREFIX}_EXECUTABLE}" NAME)
+
+  if (expected_version AND NOT python_name STREQUAL "python${expected_version}${CMAKE_EXECUTABLE_SUFFIX}")
+    # executable found must have a specific version
     execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
-                             "import sys; sys.stdout.write(str(sys.version_info[0]))"
+                             "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))"
                      RESULT_VARIABLE result
                      OUTPUT_VARIABLE version
                      ERROR_QUIET
                      OUTPUT_STRIP_TRAILING_WHITESPACE)
-    if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+    if (result OR NOT version EQUAL expected_version)
       # interpreter not usable or has wrong major version
       set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE)
       return()
     endif()
+  else()
+    if (python_name STREQUAL "python${CMAKE_EXECUTABLE_SUFFIX}")
+      # executable found do not have version in name
+      # ensure major version is OK
+      execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
+                               "import sys; sys.stdout.write(str(sys.version_info[0]))"
+                       RESULT_VARIABLE result
+                       OUTPUT_VARIABLE version
+                       ERROR_QUIET
+                       OUTPUT_STRIP_TRAILING_WHITESPACE)
+      if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+        # interpreter not usable or has wrong major version
+        set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE)
+        return()
+      endif()
+    endif()
   endif()
 
   if (CMAKE_SIZEOF_VOID_P AND "Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
@@ -183,17 +225,32 @@ else()
 endif()
 
 # Apple frameworks handling
-include (${CMAKE_CURRENT_LIST_DIR}/../CMakeFindFrameworks.cmake)
-cmake_find_frameworks (Python)
+_python_find_frameworks ()
+
+# Save CMAKE_FIND_APPBUNDLE
+if (DEFINED CMAKE_FIND_APPBUNDLE)
+  set (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
+else()
+  unset (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE)
+endif()
+# To avoid app bundle lookup
+set (CMAKE_FIND_APPBUNDLE "NEVER")
 
 # Save CMAKE_FIND_FRAMEWORK
 if (DEFINED CMAKE_FIND_FRAMEWORK)
   set (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
+  if (CMAKE_FIND_FRAMEWORK STREQUAL "ONLY")
+    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: CMAKE_FIND_FRAMEWORK: 'ONLY' value is not supported. 'FIRST' will be used instead.")
+    set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST")
+  else()
+    set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
+  endif()
 else()
   unset (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK)
+  set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST")
 endif()
-# To avoid picking up the system elements pre-maturely.
-set (CMAKE_FIND_FRAMEWORK LAST)
+# To avoid framework lookup
+set (CMAKE_FIND_FRAMEWORK "NEVER")
 
 
 unset (_${_PYTHON_PREFIX}_REQUIRED_VARS)
@@ -215,19 +272,36 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
 
     _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
 
+    # Apple frameworks handling
+    if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+      find_program (${_PYTHON_PREFIX}_EXECUTABLE
+                    NAMES python${_${_PYTHON_PREFIX}_VERSION}
+                          python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                    NAMES_PER_DIR
+                    PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+                    PATH_SUFFIXES bin
+                    NO_CMAKE_PATH
+                    NO_CMAKE_ENVIRONMENT_PATH
+                    NO_SYSTEM_ENVIRONMENT_PATH
+                    NO_CMAKE_SYSTEM_PATH)
+    endif()
+
     # try using HINTS
     find_program (${_PYTHON_PREFIX}_EXECUTABLE
                   NAMES python${_${_PYTHON_PREFIX}_VERSION}
+                        python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
                   NAMES_PER_DIR
                   HINTS ${_${_PYTHON_PREFIX}_HINTS}
-                  PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
                   PATH_SUFFIXES bin
                   NO_SYSTEM_ENVIRONMENT_PATH
                   NO_CMAKE_SYSTEM_PATH)
+
     # try using registry
     if (WIN32)
       find_program (${_PYTHON_PREFIX}_EXECUTABLE
-                    NAMES python${_${_PYTHON_PREFIX}_VERSION} python
+                    NAMES python${_${_PYTHON_PREFIX}_VERSION}
+                          python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                          python
                           ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
                     NAMES_PER_DIR
                     HINTS ${_${_PYTHON_PREFIX}_HINTS}
@@ -242,12 +316,24 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
                     NO_SYSTEM_ENVIRONMENT_PATH
                     NO_CMAKE_SYSTEM_PATH)
     endif()
+
     # try in standard paths
     find_program (${_PYTHON_PREFIX}_EXECUTABLE
                   NAMES python${_${_PYTHON_PREFIX}_VERSION}
                   NAMES_PER_DIR)
 
-    _python_validate_interpreter ()
+    # Apple frameworks handling
+    if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+      find_program (${_PYTHON_PREFIX}_EXECUTABLE
+                    NAMES python${_${_PYTHON_PREFIX}_VERSION}
+                          python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                    NAMES_PER_DIR
+                    PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+                    PATH_SUFFIXES bin
+                    NO_DEFAULT_PATH)
+    endif()
+
+    _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION})
     if (${_PYTHON_PREFIX}_EXECUTABLE)
       break()
     endif()
@@ -578,6 +664,27 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
 
       _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
 
+      if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+        find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
+                      NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}
+                            python${_${_PYTHON_PREFIX}_VERSION}mu
+                            python${_${_PYTHON_PREFIX}_VERSION}m
+                            python${_${_PYTHON_PREFIX}_VERSION}u
+                            python${_${_PYTHON_PREFIX}_VERSION}
+                      NAMES_PER_DIR
+                      PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+                      PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}u
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}
+                                    lib/python${_${_PYTHON_PREFIX}_VERSION}/config
+                      NO_CMAKE_PATH
+                      NO_CMAKE_ENVIRONMENT_PATH
+                      NO_SYSTEM_ENVIRONMENT_PATH
+                      NO_CMAKE_SYSTEM_PATH)
+      endif()
+
       # search first in known locations
       find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
                     NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}
@@ -587,8 +694,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                           python${_${_PYTHON_PREFIX}_VERSION}
                     NAMES_PER_DIR
                     HINTS ${_${_PYTHON_PREFIX}_HINTS}
-                    PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
-                          [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                    PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
                           [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
                           [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
@@ -600,6 +706,13 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                                   lib/python${_${_PYTHON_PREFIX}_VERSION}/config
                     NO_SYSTEM_ENVIRONMENT_PATH
                     NO_CMAKE_SYSTEM_PATH)
+
+      if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+        set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS})
+      else()
+        unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+      endif()
+
       # search in all default paths
       find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE
                     NAMES python${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}
@@ -608,6 +721,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                           python${_${_PYTHON_PREFIX}_VERSION}u
                           python${_${_PYTHON_PREFIX}_VERSION}
                     NAMES_PER_DIR
+                    PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
                     PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE} lib libs
                                   lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}mu
                                   lib/python${_${_PYTHON_PREFIX}_VERSION}/config-${_${_PYTHON_PREFIX}_VERSION}m
@@ -625,8 +739,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
                                             python${_${_PYTHON_PREFIX}_VERSION}
                                       NAMES_PER_DIR
                                       HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS}
-                                      PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
-                                            [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+                                      PATHS [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
                                             [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
                                             [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
                                             [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_${_PYTHON_PREFIX}_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
@@ -698,6 +811,25 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
         endforeach()
         list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_INCLUDE_HINTS)
 
+        if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+          find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
+                     NAMES Python.h
+                     HINTS ${_${_PYTHON_PREFIX}_HINTS}
+                     PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+                     PATH_SUFFIXES include/python${_${_PYTHON_PREFIX}_VERSION}mu
+                                   include/python${_${_PYTHON_PREFIX}_VERSION}m
+                                   include/python${_${_PYTHON_PREFIX}_VERSION}u
+                                   include/python${_${_PYTHON_PREFIX}_VERSION}
+                                   include
+                     NO_CMAKE_PATH
+                     NO_CMAKE_ENVIRONMENT_PATH
+                     NO_SYSTEM_ENVIRONMENT_PATH
+                     NO_CMAKE_SYSTEM_PATH)
+        endif()
+        if (NOT _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+          unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+        endif()
+
         find_path (${_PYTHON_PREFIX}_INCLUDE_DIR
                    NAMES Python.h
                    HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
@@ -921,6 +1053,13 @@ endif()
 
 # final clean-up
 
+# Restore CMAKE_FIND_APPBUNDLE
+if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE)
+  set (CMAKE_FIND_APPBUNDLE ${_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE})
+  unset (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE)
+else()
+  unset (CMAKE_FIND_APPBUNDLE)
+endif()
 # Restore CMAKE_FIND_FRAMEWORK
 if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK)
   set (CMAKE_FIND_FRAMEWORK ${_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK})
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index 22e9a8f..78ed29a 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -117,6 +117,14 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``CMAKE_FIND_FRAMEWORK``
+  On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
+  preference between Apple-style and unix-style package components.
+
+  .. note::
+
+    Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+
 Commands
 ^^^^^^^^
 
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index 99c159b..48054a9 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -117,6 +117,14 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``CMAKE_FIND_FRAMEWORK``
+  On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
+  preference between Apple-style and unix-style package components.
+
+  .. note::
+
+    Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+
 Commands
 ^^^^^^^^
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b0b53921cef242acc91e6ab4dd495daff54191d6
commit b0b53921cef242acc91e6ab4dd495daff54191d6
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Tue Sep 4 16:26:26 2018 +0200
Commit:     Marc Chevrier <marc.chevrier at gmail.com>
CommitDate: Wed Sep 12 10:04:04 2018 +0200

    FindPython: clean-up lookup names strategy

diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index fe3df91..9144ba4 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -244,7 +244,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
     endif()
     # try in standard paths
     find_program (${_PYTHON_PREFIX}_EXECUTABLE
-                  NAMES python${_${_PYTHON_PREFIX}_VERSION})
+                  NAMES python${_${_PYTHON_PREFIX}_VERSION}
+                  NAMES_PER_DIR)
 
     _python_validate_interpreter ()
     if (${_PYTHON_PREFIX}_EXECUTABLE)
@@ -252,10 +253,15 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
     endif()
   endforeach()
 
-  # try more generic names
+  # try more generic names. NAMES_PER_DIR is not specified on purpose to have a
+  # chance to find expected version.
+  # For example, typical systems have 'python' for version 2.* and 'python3'
+  # for version 3.*. So looking for names per dir will find, potentially,
+  # systematically 'python' (i.e. version 2) even if version 3 is searched.
   if (NOT ${_PYTHON_PREFIX}_EXECUTABLE)
     find_program (${_PYTHON_PREFIX}_EXECUTABLE
-                  NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python
+                  NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+                        python
                         ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
                   HINTS ${_${_PYTHON_PREFIX}_HINTS}
                   PATH_SUFFIXES bin)
@@ -483,6 +489,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
     list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES "python${_${_PYTHON_PREFIX}_VERSION}-config")
     find_program (_${_PYTHON_PREFIX}_CONFIG
                   NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+                  NAMES_PER_DIR
                   HINTS ${_${_PYTHON_PREFIX}_HINTS}
                   PATH_SUFFIXES bin)
     unset (_${_PYTHON_PREFIX}_CONFIG_NAMES)

-----------------------------------------------------------------------

Summary of changes:
 Help/command/if.rst                                |  20 +-
 Help/release/dev/FindPython-lookup-strategy.rst    |   6 +
 Help/release/dev/vs-ipo.rst                        |   6 +
 Modules/CheckIPOSupported.cmake                    |   2 +-
 Modules/FindPython.cmake                           |  19 +
 Modules/FindPython/Support.cmake                   | 416 +++++++++++++++++----
 Modules/FindPython2.cmake                          |  19 +
 Modules/FindPython3.cmake                          |  19 +
 Source/CTest/cmCTestHandlerCommand.cxx             |   4 +-
 Source/cmComputeLinkInformation.cxx                |   2 +-
 Source/cmDepends.cxx                               |   2 +-
 Source/cmExportFileGenerator.cxx                   |   2 +-
 Source/cmExtraCodeBlocksGenerator.cxx              |   2 +-
 Source/cmExtraCodeLiteGenerator.cxx                |   2 +-
 Source/cmGeneratorExpressionNode.cxx               |  30 +-
 Source/cmGeneratorTarget.cxx                       |  20 +-
 Source/cmGetDirectoryPropertyCommand.cxx           |   2 +-
 Source/cmGlobalGenerator.cxx                       |  11 +-
 Source/cmGlobalGenerator.h                         |   2 +-
 Source/cmGlobalNinjaGenerator.cxx                  |  12 +-
 Source/cmGlobalVisualStudio10Generator.h           |   2 +
 Source/cmInstallCommand.cxx                        |   4 +-
 Source/cmLocalGenerator.cxx                        |  12 +-
 Source/cmLocalUnixMakefileGenerator3.cxx           |   3 +-
 Source/cmLocalVisualStudio7Generator.cxx           |   4 +-
 Source/cmMakefile.cxx                              |  24 +-
 Source/cmMakefile.h                                |   3 +-
 Source/cmNinjaTargetGenerator.cxx                  |   6 +-
 Source/cmPolicies.cxx                              |   2 +-
 Source/cmQtAutoGenInitializer.cxx                  |   2 +-
 Source/cmQtAutoGeneratorMocUic.cxx                 |   7 +-
 Source/cmQtAutoGeneratorRcc.cxx                    |   2 +-
 Source/cmState.cxx                                 |   3 +
 Source/cmTarget.cxx                                |   6 +-
 Source/cmVisualStudio10TargetGenerator.cxx         |  47 ++-
 Source/cmVisualStudio10TargetGenerator.h           |   1 +
 Tests/RunCMake/CMP0069/RunCMakeTest.cmake          |   2 +-
 .../RunCMake/CheckIPOSupported/RunCMakeTest.cmake  |   2 +-
 38 files changed, 557 insertions(+), 173 deletions(-)
 create mode 100644 Help/release/dev/FindPython-lookup-strategy.rst
 create mode 100644 Help/release/dev/vs-ipo.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list