Browse Source

cmComputeLinkInformation: make some members const

Vitaly Stakhovsky 7 years ago
parent
commit
85468e0754
2 changed files with 34 additions and 34 deletions
  1. 20 20
      Source/cmComputeLinkInformation.cxx
  2. 14 14
      Source/cmComputeLinkInformation.h

+ 20 - 20
Source/cmComputeLinkInformation.cxx

@@ -240,21 +240,19 @@ because this need be done only for shared libraries without soname-s.
 
 cmComputeLinkInformation::cmComputeLinkInformation(
   const cmGeneratorTarget* target, const std::string& config)
-{
   // Store context information.
-  this->Target = target;
-  this->Makefile = this->Target->Target->GetMakefile();
-  this->GlobalGenerator =
-    this->Target->GetLocalGenerator()->GetGlobalGenerator();
-  this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
-
+  : Target(target),
+    Makefile(target->Target->GetMakefile()),
+    GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()),
+    CMakeInstance(this->GlobalGenerator->GetCMakeInstance())
+    // The configuration being linked.
+    ,
+    Config(config)
+{
   // Check whether to recognize OpenBSD-style library versioned names.
   this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
     "FIND_LIBRARY_USE_OPENBSD_VERSIONING");
 
-  // The configuration being linked.
-  this->Config = config;
-
   // Allocate internals.
   this->OrderLinkerSearchPath = new cmOrderDirectories(
     this->GlobalGenerator, target, "linker search path");
@@ -412,11 +410,12 @@ cmComputeLinkInformation::GetItems() const
 }
 
 std::vector<std::string> const& cmComputeLinkInformation::GetDirectories()
+  const
 {
   return this->OrderLinkerSearchPath->GetOrderedDirectories();
 }
 
-std::string cmComputeLinkInformation::GetRPathLinkString()
+std::string cmComputeLinkInformation::GetRPathLinkString() const
 {
   // If there is no separate linker runtime search flag (-rpath-link)
   // there is no reason to compute a string.
@@ -428,18 +427,19 @@ std::string cmComputeLinkInformation::GetRPathLinkString()
   return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":");
 }
 
-std::vector<std::string> const& cmComputeLinkInformation::GetDepends()
+std::vector<std::string> const& cmComputeLinkInformation::GetDepends() const
 {
   return this->Depends;
 }
 
 std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths()
+  const
 {
   return this->FrameworkPaths;
 }
 
 const std::set<const cmGeneratorTarget*>&
-cmComputeLinkInformation::GetSharedLibrariesLinked()
+cmComputeLinkInformation::GetSharedLibrariesLinked() const
 {
   return this->SharedLibrariesLinked;
 }
@@ -1026,7 +1026,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
       (generator.find("Visual Studio") != std::string::npos ||
        generator.find("Xcode") != std::string::npos)) {
     std::string file = cmSystemTools::GetFilenameName(item);
-    if (!this->ExtractAnyLibraryName.find(file.c_str())) {
+    if (!this->ExtractAnyLibraryName.find(file)) {
       this->HandleBadFullItem(item, file);
       return;
     }
@@ -1233,7 +1233,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
 void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
 {
   // Try to separate the framework name and path.
-  if (!this->SplitFramework.find(item.c_str())) {
+  if (!this->SplitFramework.find(item)) {
     std::ostringstream e;
     e << "Could not parse framework path \"" << item << "\" "
       << "linked by target " << this->Target->GetName() << ".";
@@ -1572,7 +1572,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
 }
 
 std::vector<std::string> const&
-cmComputeLinkInformation::GetRuntimeSearchPath()
+cmComputeLinkInformation::GetRuntimeSearchPath() const
 {
   return this->OrderRuntimeSearchPath->GetOrderedDirectories();
 }
@@ -1638,7 +1638,7 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo(
   if (!is_shared_library) {
     // On some platforms (AIX) a shared library may look static.
     if (this->ArchivesMayBeShared) {
-      if (this->ExtractStaticLibraryName.find(file.c_str())) {
+      if (this->ExtractStaticLibraryName.find(file)) {
         // This is the name of a shared library or archive.
         is_shared_library = true;
       }
@@ -1683,7 +1683,7 @@ static void cmCLI_ExpandListUnique(const char* str,
 }
 
 void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
-                                        bool for_install)
+                                        bool for_install) const
 {
   // Select whether to generate runtime search directories.
   bool outputRuntime =
@@ -1797,7 +1797,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
   cmCLI_ExpandListUnique(this->RuntimeAlways.c_str(), runtimeDirs, emitted);
 }
 
-std::string cmComputeLinkInformation::GetRPathString(bool for_install)
+std::string cmComputeLinkInformation::GetRPathString(bool for_install) const
 {
   // Get the directories to use.
   std::vector<std::string> runtimeDirs;
@@ -1825,7 +1825,7 @@ std::string cmComputeLinkInformation::GetRPathString(bool for_install)
   return rpath;
 }
 
-std::string cmComputeLinkInformation::GetChrpathString()
+std::string cmComputeLinkInformation::GetChrpathString() const
 {
   if (!this->RuntimeUseChrpath) {
     return "";

+ 14 - 14
Source/cmComputeLinkInformation.h

@@ -49,20 +49,20 @@ public:
   };
   typedef std::vector<Item> ItemVector;
   ItemVector const& GetItems() const;
-  std::vector<std::string> const& GetDirectories();
-  std::vector<std::string> const& GetDepends();
-  std::vector<std::string> const& GetFrameworkPaths();
+  std::vector<std::string> const& GetDirectories() const;
+  std::vector<std::string> const& GetDepends() const;
+  std::vector<std::string> const& GetFrameworkPaths() const;
   std::string GetLinkLanguage() const { return this->LinkLanguage; }
-  std::vector<std::string> const& GetRuntimeSearchPath();
+  std::vector<std::string> const& GetRuntimeSearchPath() const;
   std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
   std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
-  void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
-  std::string GetRPathString(bool for_install);
-  std::string GetChrpathString();
-  std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked();
+  void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install) const;
+  std::string GetRPathString(bool for_install) const;
+  std::string GetChrpathString() const;
+  std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked() const;
 
   std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
-  std::string GetRPathLinkString();
+  std::string GetRPathLinkString() const;
 
   std::string GetConfig() const { return this->Config; }
 private:
@@ -78,13 +78,13 @@ private:
   std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
 
   // Context information.
-  cmGeneratorTarget const* Target;
-  cmMakefile* Makefile;
-  cmGlobalGenerator* GlobalGenerator;
-  cmake* CMakeInstance;
+  cmGeneratorTarget const* const Target;
+  cmMakefile* const Makefile;
+  cmGlobalGenerator* const GlobalGenerator;
+  cmake* const CMakeInstance;
 
   // Configuration information.
-  std::string Config;
+  std::string const Config;
   std::string LinkLanguage;
 
   // Modes for dealing with dependent shared libraries.