Browse Source

Merge topic 'misc-messages'

dbe33b20bd install: Add context to {PUBLIC,PRIVATE}_HEADER/RESOURCE DESTINATION warnings
1a25f057da cmComputeLinkInformation: Add context to warning about linking a directory
4862f3b2c8 cmcmd: Write progress and tar errors directly to stderr
efc6c23a47 bootstrap: Do not declare cmSystemTools functions that are not implemented

Acked-by: Kitware Robot <[email protected]>
Tested-by: buildbot <[email protected]>
Merge-request: !6680
Brad King 4 years ago
parent
commit
562ee8a50b

+ 9 - 8
Source/cmComputeLinkInformation.cxx

@@ -722,7 +722,7 @@ void cmComputeLinkInformation::AddItem(BT<std::string> const& item,
         this->AddFrameworkItem(item.Value);
         this->AddFrameworkItem(item.Value);
       } else if (cmSystemTools::FileIsDirectory(item.Value)) {
       } else if (cmSystemTools::FileIsDirectory(item.Value)) {
         // This is a directory.
         // This is a directory.
-        this->DropDirectoryItem(item.Value);
+        this->DropDirectoryItem(item);
       } else {
       } else {
         // Use the full path given to the library file.
         // Use the full path given to the library file.
         this->Depends.push_back(item.Value);
         this->Depends.push_back(item.Value);
@@ -1349,16 +1349,17 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
   }
   }
 }
 }
 
 
-void cmComputeLinkInformation::DropDirectoryItem(std::string const& item)
+void cmComputeLinkInformation::DropDirectoryItem(BT<std::string> const& item)
 {
 {
   // A full path to a directory was found as a link item.  Warn the
   // A full path to a directory was found as a link item.  Warn the
   // user.
   // user.
-  std::ostringstream e;
-  e << "WARNING: Target \"" << this->Target->GetName()
-    << "\" requests linking to directory \"" << item << "\".  "
-    << "Targets may link only to libraries.  "
-    << "CMake is dropping the item.";
-  cmSystemTools::Message(e.str());
+  this->CMakeInstance->IssueMessage(
+    MessageType::WARNING,
+    cmStrCat(
+      "Target \"", this->Target->GetName(),
+      "\" requests linking to directory \"", item.Value,
+      "\".  Targets may link only to libraries.  CMake is dropping the item."),
+    item.Backtrace);
 }
 }
 
 
 void cmComputeLinkInformation::ComputeFrameworkInfo()
 void cmComputeLinkInformation::ComputeFrameworkInfo()

+ 1 - 1
Source/cmComputeLinkInformation.h

@@ -187,7 +187,7 @@ private:
   bool CheckImplicitDirItem(std::string const& item);
   bool CheckImplicitDirItem(std::string const& item);
   void AddUserItem(BT<std::string> const& item, bool pathNotKnown);
   void AddUserItem(BT<std::string> const& item, bool pathNotKnown);
   void AddFrameworkItem(std::string const& item);
   void AddFrameworkItem(std::string const& item);
-  void DropDirectoryItem(std::string const& item);
+  void DropDirectoryItem(BT<std::string> const& item);
   bool CheckSharedLibNoSOName(std::string const& item);
   bool CheckSharedLibNoSOName(std::string const& item);
   void AddSharedLibNoSOName(std::string const& item);
   void AddSharedLibNoSOName(std::string const& item);
   void HandleBadFullItem(std::string const& item, std::string const& file);
   void HandleBadFullItem(std::string const& item, std::string const& file);

+ 8 - 8
Source/cmInstallCommand.cxx

@@ -1026,9 +1026,9 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
             helper.GetIncludeDestination(&privateHeaderArgs));
             helper.GetIncludeDestination(&privateHeaderArgs));
         } else {
         } else {
           std::ostringstream e;
           std::ostringstream e;
-          e << "INSTALL TARGETS - target " << target.GetName() << " has "
+          e << "Target " << target.GetName() << " has "
             << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
             << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
-          cmSystemTools::Message(e.str(), "Warning");
+          helper.Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
         }
         }
       }
       }
 
 
@@ -1048,9 +1048,9 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
             helper.GetIncludeDestination(&publicHeaderArgs));
             helper.GetIncludeDestination(&publicHeaderArgs));
         } else {
         } else {
           std::ostringstream e;
           std::ostringstream e;
-          e << "INSTALL TARGETS - target " << target.GetName() << " has "
+          e << "Target " << target.GetName() << " has "
             << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
             << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
-          cmSystemTools::Message(e.str(), "Warning");
+          helper.Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
         }
         }
       }
       }
 
 
@@ -1067,10 +1067,10 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
           resourceGenerator = CreateInstallFilesGenerator(
           resourceGenerator = CreateInstallFilesGenerator(
             helper.Makefile, absFiles, resourceArgs, false);
             helper.Makefile, absFiles, resourceArgs, false);
         } else if (!target.IsAppBundleOnApple()) {
         } else if (!target.IsAppBundleOnApple()) {
-          cmSystemTools::Message(
-            cmStrCat("INSTALL TARGETS - target ", target.GetName(),
-                     " has RESOURCE files but no RESOURCE DESTINATION."),
-            "Warning");
+          helper.Makefile->IssueMessage(
+            MessageType::AUTHOR_WARNING,
+            cmStrCat("Target ", target.GetName(),
+                     " has RESOURCE files but no RESOURCE DESTINATION."));
         }
         }
       }
       }
     }
     }

+ 2 - 0
Source/cmInstallExportGenerator.cxx

@@ -85,7 +85,9 @@ void cmInstallExportGenerator::ComputeTempDir()
   }
   }
   if (useMD5) {
   if (useMD5) {
     // Replace the destination path with a hash to keep it short.
     // Replace the destination path with a hash to keep it short.
+#ifndef CMAKE_BOOTSTRAP
     this->TempDir += cmSystemTools::ComputeStringMD5(this->Destination);
     this->TempDir += cmSystemTools::ComputeStringMD5(this->Destination);
+#endif
   } else {
   } else {
     std::string dest = this->Destination;
     std::string dest = this->Destination;
     // Avoid unix full paths.
     // Avoid unix full paths.

+ 4 - 1
Source/cmLocalGenerator.cxx

@@ -2831,7 +2831,10 @@ void cmLocalGenerator::IncludeFileInUnitySources(
     unity_file << "/* " << pathToHash << " */\n"
     unity_file << "/* " << pathToHash << " */\n"
                << "#undef " << *uniqueIdName << "\n"
                << "#undef " << *uniqueIdName << "\n"
                << "#define " << *uniqueIdName << " unity_"
                << "#define " << *uniqueIdName << " unity_"
-               << cmSystemTools::ComputeStringMD5(pathToHash) << "\n";
+#ifndef CMAKE_BOOTSTRAP
+               << cmSystemTools::ComputeStringMD5(pathToHash) << "\n"
+#endif
+      ;
   }
   }
 
 
   if (beforeInclude) {
   if (beforeInclude) {

+ 4 - 20
Source/cmSystemTools.cxx

@@ -1158,39 +1158,26 @@ void cmSystemTools::MoveFileIfDifferent(const std::string& source,
   RemoveFile(source);
   RemoveFile(source);
 }
 }
 
 
+#ifndef CMAKE_BOOTSTRAP
 std::string cmSystemTools::ComputeFileHash(const std::string& source,
 std::string cmSystemTools::ComputeFileHash(const std::string& source,
                                            cmCryptoHash::Algo algo)
                                            cmCryptoHash::Algo algo)
 {
 {
-#if !defined(CMAKE_BOOTSTRAP)
   cmCryptoHash hash(algo);
   cmCryptoHash hash(algo);
   return hash.HashFile(source);
   return hash.HashFile(source);
-#else
-  (void)source;
-  cmSystemTools::Message("hashsum not supported in bootstrapping mode",
-                         "Error");
-  return std::string();
-#endif
 }
 }
 
 
 std::string cmSystemTools::ComputeStringMD5(const std::string& input)
 std::string cmSystemTools::ComputeStringMD5(const std::string& input)
 {
 {
-#if !defined(CMAKE_BOOTSTRAP)
   cmCryptoHash md5(cmCryptoHash::AlgoMD5);
   cmCryptoHash md5(cmCryptoHash::AlgoMD5);
   return md5.HashString(input);
   return md5.HashString(input);
-#else
-  (void)input;
-  cmSystemTools::Message("md5sum not supported in bootstrapping mode",
-                         "Error");
-  return "";
-#endif
 }
 }
 
 
+#  ifdef _WIN32
 std::string cmSystemTools::ComputeCertificateThumbprint(
 std::string cmSystemTools::ComputeCertificateThumbprint(
   const std::string& source)
   const std::string& source)
 {
 {
   std::string thumbprint;
   std::string thumbprint;
 
 
-#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32)
   CRYPT_INTEGER_BLOB cryptBlob;
   CRYPT_INTEGER_BLOB cryptBlob;
   HCERTSTORE certStore = NULL;
   HCERTSTORE certStore = NULL;
   PCCERT_CONTEXT certContext = NULL;
   PCCERT_CONTEXT certContext = NULL;
@@ -1247,14 +1234,11 @@ std::string cmSystemTools::ComputeCertificateThumbprint(
     }
     }
     CloseHandle(certFile);
     CloseHandle(certFile);
   }
   }
-#else
-  (void)source;
-  cmSystemTools::Message("ComputeCertificateThumbprint is not implemented",
-                         "Error");
-#endif
 
 
   return thumbprint;
   return thumbprint;
 }
 }
+#  endif
+#endif
 
 
 void cmSystemTools::Glob(const std::string& directory,
 void cmSystemTools::Glob(const std::string& directory,
                          const std::string& regexp,
                          const std::string& regexp,

+ 4 - 0
Source/cmSystemTools.h

@@ -179,6 +179,7 @@ public:
   static void MoveFileIfDifferent(const std::string& source,
   static void MoveFileIfDifferent(const std::string& source,
                                   const std::string& destination);
                                   const std::string& destination);
 
 
+#ifndef CMAKE_BOOTSTRAP
   //! Compute the hash of a file
   //! Compute the hash of a file
   static std::string ComputeFileHash(const std::string& source,
   static std::string ComputeFileHash(const std::string& source,
                                      cmCryptoHash::Algo algo);
                                      cmCryptoHash::Algo algo);
@@ -186,8 +187,11 @@ public:
   /** Compute the md5sum of a string.  */
   /** Compute the md5sum of a string.  */
   static std::string ComputeStringMD5(const std::string& input);
   static std::string ComputeStringMD5(const std::string& input);
 
 
+#  ifdef _WIN32
   //! Get the SHA thumbprint for a certificate file
   //! Get the SHA thumbprint for a certificate file
   static std::string ComputeCertificateThumbprint(const std::string& source);
   static std::string ComputeCertificateThumbprint(const std::string& source);
+#  endif
+#endif
 
 
   /**
   /**
    * Run a single executable command
    * Run a single executable command

+ 9 - 7
Source/cmcmd.cxx

@@ -1112,7 +1112,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
       int count;
       int count;
       if (countFile) {
       if (countFile) {
         if (1 != fscanf(countFile, "%i", &count)) {
         if (1 != fscanf(countFile, "%i", &count)) {
-          cmSystemTools::Message("Could not read from count file.");
+          std::cerr << "Could not read from count file.\n";
         }
         }
         fclose(countFile);
         fclose(countFile);
       } else {
       } else {
@@ -1426,8 +1426,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
             action = cmSystemTools::TarActionExtract;
             action = cmSystemTools::TarActionExtract;
           } break;
           } break;
           default: {
           default: {
-            cmSystemTools::Message(
-              std::string("tar: Unknown argument: ") + flag, "Warning");
+            std::cerr << "tar: Unknown argument: " << flag << "\n";
           }
           }
         }
         }
       }
       }
@@ -1448,8 +1447,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
         }
         }
       } else if (action == cmSystemTools::TarActionCreate) {
       } else if (action == cmSystemTools::TarActionCreate) {
         if (files.empty()) {
         if (files.empty()) {
-          cmSystemTools::Message("tar: No files or directories specified",
-                                 "Warning");
+          std::cerr << "tar: No files or directories specified\n";
         }
         }
         if (!cmSystemTools::CreateTar(outFile, files, compress, verbose, mtime,
         if (!cmSystemTools::CreateTar(outFile, files, compress, verbose, mtime,
                                       format)) {
                                       format)) {
@@ -1588,7 +1586,11 @@ int cmcmd::HashSumFile(std::vector<std::string> const& args,
       std::cerr << "Error: " << filename << " is a directory" << std::endl;
       std::cerr << "Error: " << filename << " is a directory" << std::endl;
       retval++;
       retval++;
     } else {
     } else {
-      std::string value = cmSystemTools::ComputeFileHash(filename, algo);
+      std::string value
+#ifndef CMAKE_BOOTSTRAP
+        = cmSystemTools::ComputeFileHash(filename, algo)
+#endif
+        ;
       if (value.empty()) {
       if (value.empty()) {
         // To mimic "md5sum/shasum" behavior in a shell:
         // To mimic "md5sum/shasum" behavior in a shell:
         std::cerr << filename << ": No such file or directory" << std::endl;
         std::cerr << filename << ": No such file or directory" << std::endl;
@@ -1684,7 +1686,7 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num)
     return;
     return;
   }
   }
   if (1 != fscanf(progFile, "%i", &count)) {
   if (1 != fscanf(progFile, "%i", &count)) {
-    cmSystemTools::Message("Could not read from progress file.");
+    std::cerr << "Could not read from progress file.\n";
   }
   }
   fclose(progFile);
   fclose(progFile);
 
 

+ 11 - 2
Tests/RunCMake/install/TARGETS-Defaults-Cache-stderr.txt

@@ -1,2 +1,11 @@
-^INSTALL TARGETS - target lib3 has PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION\.
-INSTALL TARGETS - target lib4 has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION\.$
+^CMake Warning \(dev\) at TARGETS-Defaults-Cache.cmake:[0-9]+ \(install\):
+  Target lib3 has PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at TARGETS-Defaults-Cache.cmake:[0-9]+ \(install\):
+  Target lib4 has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.$

+ 11 - 2
Tests/RunCMake/install/TARGETS-Defaults-stderr.txt

@@ -1,2 +1,11 @@
-^INSTALL TARGETS - target lib3 has PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION\.
-INSTALL TARGETS - target lib4 has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION\.$
+^CMake Warning \(dev\) at TARGETS-Defaults.cmake:[0-9]+ \(install\):
+  Target lib3 has PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at TARGETS-Defaults.cmake:[0-9]+ \(install\):
+  Target lib4 has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.$