Explorar o código

Replace boolean `implib` parameters with enum

Named enumeration values are much clearer at call sites and add more
type safety.
Gregor Jasny %!s(int64=8) %!d(string=hai) anos
pai
achega
cf320f7cd7

+ 16 - 4
Source/cmComputeLinkInformation.cxx

@@ -500,7 +500,10 @@ bool cmComputeLinkInformation::Compute()
       cmGeneratorTarget const* tgt = *i;
       cmGeneratorTarget const* tgt = *i;
       bool implib = (this->UseImportLibrary &&
       bool implib = (this->UseImportLibrary &&
                      (tgt->GetType() == cmStateEnums::SHARED_LIBRARY));
                      (tgt->GetType() == cmStateEnums::SHARED_LIBRARY));
-      std::string lib = tgt->GetFullPath(this->Config, implib, true);
+      cmStateEnums::ArtifactType artifact = implib
+        ? cmStateEnums::ImportLibraryArtifact
+        : cmStateEnums::RuntimeBinaryArtifact;
+      std::string lib = tgt->GetFullPath(this->Config, artifact, true);
       this->OldLinkDirItems.push_back(lib);
       this->OldLinkDirItems.push_back(lib);
     }
     }
   }
   }
@@ -596,8 +599,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
       // platform.  Add it now.
       // platform.  Add it now.
       std::string linkItem;
       std::string linkItem;
       linkItem = this->LoaderFlag;
       linkItem = this->LoaderFlag;
+      cmStateEnums::ArtifactType artifact = this->UseImportLibrary
+        ? cmStateEnums::ImportLibraryArtifact
+        : cmStateEnums::RuntimeBinaryArtifact;
 
 
-      std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true);
+      std::string exe = tgt->GetFullPath(config, artifact, true);
       linkItem += exe;
       linkItem += exe;
       this->Items.push_back(Item(linkItem, true, tgt));
       this->Items.push_back(Item(linkItem, true, tgt));
       this->Depends.push_back(exe);
       this->Depends.push_back(exe);
@@ -617,9 +623,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
       bool implib =
       bool implib =
         (this->UseImportLibrary &&
         (this->UseImportLibrary &&
          (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY));
          (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY));
+      cmStateEnums::ArtifactType artifact = implib
+        ? cmStateEnums::ImportLibraryArtifact
+        : cmStateEnums::RuntimeBinaryArtifact;
 
 
       // Pass the full path to the target file.
       // Pass the full path to the target file.
-      std::string lib = tgt->GetFullPath(config, implib, true);
+      std::string lib = tgt->GetFullPath(config, artifact, true);
       if (!this->LinkDependsNoShared ||
       if (!this->LinkDependsNoShared ||
           tgt->GetType() != cmStateEnums::SHARED_LIBRARY) {
           tgt->GetType() != cmStateEnums::SHARED_LIBRARY) {
         this->Depends.push_back(lib);
         this->Depends.push_back(lib);
@@ -689,7 +698,10 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
   // linked will be able to find it.
   // linked will be able to find it.
   std::string lib;
   std::string lib;
   if (tgt) {
   if (tgt) {
-    lib = tgt->GetFullPath(this->Config, this->UseImportLibrary);
+    cmStateEnums::ArtifactType artifact = this->UseImportLibrary
+      ? cmStateEnums::ImportLibraryArtifact
+      : cmStateEnums::RuntimeBinaryArtifact;
+    lib = tgt->GetFullPath(this->Config, artifact);
     this->AddLibraryRuntimeInfo(lib, tgt);
     this->AddLibraryRuntimeInfo(lib, tgt);
   } else {
   } else {
     lib = item;
     lib = item;

+ 6 - 3
Source/cmExportBuildFileGenerator.cxx

@@ -200,9 +200,11 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
       prop += suffix;
       prop += suffix;
       std::string value;
       std::string value;
       if (target->IsAppBundleOnApple()) {
       if (target->IsAppBundleOnApple()) {
-        value = target->GetFullPath(config, false);
+        value =
+          target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
       } else {
       } else {
-        value = target->GetFullPath(config, false, true);
+        value = target->GetFullPath(config,
+                                    cmStateEnums::RuntimeBinaryArtifact, true);
       }
       }
       properties[prop] = value;
       properties[prop] = value;
     }
     }
@@ -212,7 +214,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
         mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
         mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
       std::string prop = "IMPORTED_IMPLIB";
       std::string prop = "IMPORTED_IMPLIB";
       prop += suffix;
       prop += suffix;
-      std::string value = target->GetFullPath(config, true);
+      std::string value =
+        target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact);
       target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
       target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
       properties[prop] = value;
       properties[prop] = value;
     }
     }

+ 6 - 2
Source/cmGeneratorExpressionNode.cxx

@@ -1607,7 +1607,10 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag>
                     "executables with ENABLE_EXPORTS.");
                     "executables with ENABLE_EXPORTS.");
       return std::string();
       return std::string();
     }
     }
-    return target->GetFullPath(context->Config, target->HasImportLibrary());
+    cmStateEnums::ArtifactType artifact = target->HasImportLibrary()
+      ? cmStateEnums::ImportLibraryArtifact
+      : cmStateEnums::RuntimeBinaryArtifact;
+    return target->GetFullPath(context->Config, artifact);
   }
   }
 };
 };
 
 
@@ -1668,7 +1671,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactNameTag>
                             cmGeneratorExpressionContext* context,
                             cmGeneratorExpressionContext* context,
                             const GeneratorExpressionContent* /*unused*/)
                             const GeneratorExpressionContent* /*unused*/)
   {
   {
-    return target->GetFullPath(context->Config, false, true);
+    return target->GetFullPath(context->Config,
+                               cmStateEnums::RuntimeBinaryArtifact, true);
   }
   }
 };
 };
 
 

+ 131 - 95
Source/cmGeneratorTarget.cxx

@@ -216,52 +216,60 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
   return this->Target->GetProperty(prop);
   return this->Target->GetProperty(prop);
 }
 }
 
 
-const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
+const char* cmGeneratorTarget::GetOutputTargetType(
+  cmStateEnums::ArtifactType artifact) const
 {
 {
   switch (this->GetType()) {
   switch (this->GetType()) {
     case cmStateEnums::SHARED_LIBRARY:
     case cmStateEnums::SHARED_LIBRARY:
       if (this->IsDLLPlatform()) {
       if (this->IsDLLPlatform()) {
-        if (implib) {
-          // A DLL import library is treated as an archive target.
-          return "ARCHIVE";
+        switch (artifact) {
+          case cmStateEnums::RuntimeBinaryArtifact:
+            // A DLL shared library is treated as a runtime target.
+            return "RUNTIME";
+          case cmStateEnums::ImportLibraryArtifact:
+            // A DLL import library is treated as an archive target.
+            return "ARCHIVE";
         }
         }
-        // A DLL shared library is treated as a runtime target.
-        return "RUNTIME";
       } else {
       } else {
         // For non-DLL platforms shared libraries are treated as
         // For non-DLL platforms shared libraries are treated as
         // library targets.
         // library targets.
         return "LIBRARY";
         return "LIBRARY";
       }
       }
+      break;
     case cmStateEnums::STATIC_LIBRARY:
     case cmStateEnums::STATIC_LIBRARY:
       // Static libraries are always treated as archive targets.
       // Static libraries are always treated as archive targets.
       return "ARCHIVE";
       return "ARCHIVE";
     case cmStateEnums::MODULE_LIBRARY:
     case cmStateEnums::MODULE_LIBRARY:
-      if (implib) {
-        // Module libraries are always treated as library targets.
-        return "ARCHIVE";
-      } else {
-        // Module import libraries are treated as archive targets.
-        return "LIBRARY";
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          // Module import libraries are treated as archive targets.
+          return "LIBRARY";
+        case cmStateEnums::ImportLibraryArtifact:
+          // Module libraries are always treated as library targets.
+          return "ARCHIVE";
       }
       }
+      break;
     case cmStateEnums::EXECUTABLE:
     case cmStateEnums::EXECUTABLE:
-      if (implib) {
-        // Executable import libraries are treated as archive targets.
-        return "ARCHIVE";
-      } else {
-        // Executables are always treated as runtime targets.
-        return "RUNTIME";
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          // Executables are always treated as runtime targets.
+          return "RUNTIME";
+        case cmStateEnums::ImportLibraryArtifact:
+          // Executable import libraries are treated as archive targets.
+          return "ARCHIVE";
       }
       }
+      break;
     default:
     default:
       break;
       break;
   }
   }
   return "";
   return "";
 }
 }
 
 
-std::string cmGeneratorTarget::GetOutputName(const std::string& config,
-                                             bool implib) const
+std::string cmGeneratorTarget::GetOutputName(
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   // Lookup/compute/cache the output name for this configuration.
   // Lookup/compute/cache the output name for this configuration.
-  OutputNameKey key(config, implib);
+  OutputNameKey key(config, artifact);
   cmGeneratorTarget::OutputNameMapType::iterator i =
   cmGeneratorTarget::OutputNameMapType::iterator i =
     this->OutputNameMap.find(key);
     this->OutputNameMap.find(key);
   if (i == this->OutputNameMap.end()) {
   if (i == this->OutputNameMap.end()) {
@@ -271,7 +279,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config,
 
 
     // Compute output name.
     // Compute output name.
     std::vector<std::string> props;
     std::vector<std::string> props;
-    std::string type = this->GetOutputTargetType(implib);
+    std::string type = this->GetOutputTargetType(artifact);
     std::string configUpper = cmSystemTools::UpperCase(config);
     std::string configUpper = cmSystemTools::UpperCase(config);
     if (!type.empty() && !configUpper.empty()) {
     if (!type.empty() && !configUpper.empty()) {
       // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
       // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
@@ -641,9 +649,10 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const
 {
 {
   static std::string location;
   static std::string location;
   if (this->IsImported()) {
   if (this->IsImported()) {
-    location = this->Target->ImportedGetFullPath(config, false);
+    location = this->Target->ImportedGetFullPath(
+      config, cmStateEnums::RuntimeBinaryArtifact);
   } else {
   } else {
-    location = this->GetFullPath(config, false);
+    location = this->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
   }
   }
   return location.c_str();
   return location.c_str();
 }
 }
@@ -680,7 +689,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const
 {
 {
   static std::string location;
   static std::string location;
   if (this->IsImported()) {
   if (this->IsImported()) {
-    location = this->Target->ImportedGetFullPath("", false);
+    location = this->Target->ImportedGetFullPath(
+      "", cmStateEnums::RuntimeBinaryArtifact);
     return location.c_str();
     return location.c_str();
   }
   }
 
 
@@ -700,7 +710,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const
     }
     }
   }
   }
   location += "/";
   location += "/";
-  location += this->GetFullName("", false);
+  location += this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact);
   return location.c_str();
   return location.c_str();
 }
 }
 
 
@@ -1145,7 +1155,8 @@ std::string cmGeneratorTarget::GetCompilePDBName(
   std::string prefix;
   std::string prefix;
   std::string base;
   std::string base;
   std::string suffix;
   std::string suffix;
-  this->GetFullNameInternal(config, false, prefix, base, suffix);
+  this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact,
+                            prefix, base, suffix);
 
 
   // Check for a per-configuration output directory target property.
   // Check for a per-configuration output directory target property.
   std::string configUpper = cmSystemTools::UpperCase(config);
   std::string configUpper = cmSystemTools::UpperCase(config);
@@ -1506,7 +1517,8 @@ static bool shouldAddContentLevel(
 std::string cmGeneratorTarget::GetAppBundleDirectory(
 std::string cmGeneratorTarget::GetAppBundleDirectory(
   const std::string& config, BundleDirectoryLevel level) const
   const std::string& config, BundleDirectoryLevel level) const
 {
 {
-  std::string fpath = this->GetFullName(config, false);
+  std::string fpath =
+    this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact);
   fpath += ".";
   fpath += ".";
   const char* ext = this->GetProperty("BUNDLE_EXTENSION");
   const char* ext = this->GetProperty("BUNDLE_EXTENSION");
   if (!ext) {
   if (!ext) {
@@ -1532,7 +1544,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(
   const std::string& config, BundleDirectoryLevel level) const
   const std::string& config, BundleDirectoryLevel level) const
 {
 {
   std::string fpath;
   std::string fpath;
-  fpath += this->GetOutputName(config, false);
+  fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact);
   fpath += ".";
   fpath += ".";
   const char* ext = this->GetProperty("BUNDLE_EXTENSION");
   const char* ext = this->GetProperty("BUNDLE_EXTENSION");
   if (!ext) {
   if (!ext) {
@@ -1556,7 +1568,7 @@ std::string cmGeneratorTarget::GetFrameworkDirectory(
   const std::string& config, BundleDirectoryLevel level) const
   const std::string& config, BundleDirectoryLevel level) const
 {
 {
   std::string fpath;
   std::string fpath;
-  fpath += this->GetOutputName(config, false);
+  fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact);
   fpath += ".";
   fpath += ".";
   const char* ext = this->GetProperty("BUNDLE_EXTENSION");
   const char* ext = this->GetProperty("BUNDLE_EXTENSION");
   if (!ext) {
   if (!ext) {
@@ -1570,13 +1582,13 @@ std::string cmGeneratorTarget::GetFrameworkDirectory(
   return fpath;
   return fpath;
 }
 }
 
 
-std::string cmGeneratorTarget::GetFullName(const std::string& config,
-                                           bool implib) const
+std::string cmGeneratorTarget::GetFullName(
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   if (this->IsImported()) {
   if (this->IsImported()) {
-    return this->GetFullNameImported(config, implib);
+    return this->GetFullNameImported(config, artifact);
   }
   }
-  return this->GetFullNameInternal(config, implib);
+  return this->GetFullNameInternal(config, artifact);
 }
 }
 
 
 std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
 std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
@@ -1869,13 +1881,11 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
   }
   }
 }
 }
 
 
-void cmGeneratorTarget::GetFullNameComponents(std::string& prefix,
-                                              std::string& base,
-                                              std::string& suffix,
-                                              const std::string& config,
-                                              bool implib) const
+void cmGeneratorTarget::GetFullNameComponents(
+  std::string& prefix, std::string& base, std::string& suffix,
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
-  this->GetFullNameInternal(config, implib, prefix, base, suffix);
+  this->GetFullNameInternal(config, artifact, prefix, base, suffix);
 }
 }
 
 
 std::string cmGeneratorTarget::BuildBundleDirectory(
 std::string cmGeneratorTarget::BuildBundleDirectory(
@@ -1896,10 +1906,10 @@ std::string cmGeneratorTarget::BuildBundleDirectory(
 }
 }
 
 
 std::string cmGeneratorTarget::GetMacContentDirectory(
 std::string cmGeneratorTarget::GetMacContentDirectory(
-  const std::string& config, bool implib) const
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   // Start with the output directory for the target.
   // Start with the output directory for the target.
-  std::string fpath = this->GetDirectory(config, implib);
+  std::string fpath = this->GetDirectory(config, artifact);
   fpath += "/";
   fpath += "/";
   BundleDirectoryLevel level = ContentLevel;
   BundleDirectoryLevel level = ContentLevel;
   if (this->IsFrameworkOnApple()) {
   if (this->IsFrameworkOnApple()) {
@@ -2860,7 +2870,8 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
   }
   }
 
 
   // Get the directory.
   // Get the directory.
-  std::string dir = this->GetDirectory(config, false);
+  std::string dir =
+    this->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact);
 
 
   // Add each name.
   // Add each name.
   std::string f;
   std::string f;
@@ -2889,7 +2900,7 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
     gg->AddToManifest(f);
     gg->AddToManifest(f);
   }
   }
   if (!impName.empty()) {
   if (!impName.empty()) {
-    f = this->GetDirectory(config, true);
+    f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact);
     f += "/";
     f += "/";
     f += impName;
     f += impName;
     gg->AddToManifest(f);
     gg->AddToManifest(f);
@@ -2907,19 +2918,20 @@ std::string cmGeneratorTarget::GetImportedLibName(
 }
 }
 
 
 std::string cmGeneratorTarget::GetFullPath(const std::string& config,
 std::string cmGeneratorTarget::GetFullPath(const std::string& config,
-                                           bool implib, bool realname) const
+                                           cmStateEnums::ArtifactType artifact,
+                                           bool realname) const
 {
 {
   if (this->IsImported()) {
   if (this->IsImported()) {
-    return this->Target->ImportedGetFullPath(config, implib);
+    return this->Target->ImportedGetFullPath(config, artifact);
   }
   }
-  return this->NormalGetFullPath(config, implib, realname);
+  return this->NormalGetFullPath(config, artifact, realname);
 }
 }
 
 
-std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
-                                                 bool implib,
-                                                 bool realname) const
+std::string cmGeneratorTarget::NormalGetFullPath(
+  const std::string& config, cmStateEnums::ArtifactType artifact,
+  bool realname) const
 {
 {
-  std::string fpath = this->GetDirectory(config, implib);
+  std::string fpath = this->GetDirectory(config, artifact);
   fpath += "/";
   fpath += "/";
   if (this->IsAppBundleOnApple()) {
   if (this->IsAppBundleOnApple()) {
     fpath = this->BuildBundleDirectory(fpath, config, FullLevel);
     fpath = this->BuildBundleDirectory(fpath, config, FullLevel);
@@ -2927,12 +2939,18 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
   }
   }
 
 
   // Add the full name of the target.
   // Add the full name of the target.
-  if (implib) {
-    fpath += this->GetFullName(config, true);
-  } else if (realname) {
-    fpath += this->NormalGetRealName(config);
-  } else {
-    fpath += this->GetFullName(config, false);
+  switch (artifact) {
+    case cmStateEnums::RuntimeBinaryArtifact:
+      if (realname) {
+        fpath += this->NormalGetRealName(config);
+      } else {
+        fpath +=
+          this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact);
+      }
+      break;
+    case cmStateEnums::ImportLibraryArtifact:
+      fpath += this->GetFullName(config, cmStateEnums::ImportLibraryArtifact);
+      break;
   }
   }
   return fpath;
   return fpath;
 }
 }
@@ -3009,7 +3027,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
   std::string prefix;
   std::string prefix;
   std::string base;
   std::string base;
   std::string suffix;
   std::string suffix;
-  this->GetFullNameInternal(config, false, prefix, base, suffix);
+  this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact,
+                            prefix, base, suffix);
 
 
   // The library name.
   // The library name.
   name = prefix + base + suffix;
   name = prefix + base + suffix;
@@ -3034,7 +3053,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
   // The import library name.
   // The import library name.
   if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
   if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
       this->GetType() == cmStateEnums::MODULE_LIBRARY) {
       this->GetType() == cmStateEnums::MODULE_LIBRARY) {
-    impName = this->GetFullNameInternal(config, true);
+    impName =
+      this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact);
   } else {
   } else {
     impName = "";
     impName = "";
   }
   }
@@ -3075,7 +3095,8 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
   std::string prefix;
   std::string prefix;
   std::string base;
   std::string base;
   std::string suffix;
   std::string suffix;
-  this->GetFullNameInternal(config, false, prefix, base, suffix);
+  this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact,
+                            prefix, base, suffix);
 
 
   // The executable name.
   // The executable name.
   name = prefix + base + suffix;
   name = prefix + base + suffix;
@@ -3095,19 +3116,20 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
 #endif
 #endif
 
 
   // The import library name.
   // The import library name.
-  impName = this->GetFullNameInternal(config, true);
+  impName =
+    this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact);
 
 
   // The program database file name.
   // The program database file name.
   pdbName = this->GetPDBName(config);
   pdbName = this->GetPDBName(config);
 }
 }
 
 
-std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config,
-                                                   bool implib) const
+std::string cmGeneratorTarget::GetFullNameInternal(
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   std::string prefix;
   std::string prefix;
   std::string base;
   std::string base;
   std::string suffix;
   std::string suffix;
-  this->GetFullNameInternal(config, implib, prefix, base, suffix);
+  this->GetFullNameInternal(config, artifact, prefix, base, suffix);
   return prefix + base + suffix;
   return prefix + base + suffix;
 }
 }
 
 
@@ -3116,22 +3138,21 @@ const char* cmGeneratorTarget::ImportedGetLocation(
 {
 {
   static std::string location;
   static std::string location;
   assert(this->IsImported());
   assert(this->IsImported());
-  location = this->Target->ImportedGetFullPath(config, false);
+  location = this->Target->ImportedGetFullPath(
+    config, cmStateEnums::RuntimeBinaryArtifact);
   return location.c_str();
   return location.c_str();
 }
 }
 
 
-std::string cmGeneratorTarget::GetFullNameImported(const std::string& config,
-                                                   bool implib) const
+std::string cmGeneratorTarget::GetFullNameImported(
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   return cmSystemTools::GetFilenameName(
   return cmSystemTools::GetFilenameName(
-    this->Target->ImportedGetFullPath(config, implib));
+    this->Target->ImportedGetFullPath(config, artifact));
 }
 }
 
 
-void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
-                                            bool implib,
-                                            std::string& outPrefix,
-                                            std::string& outBase,
-                                            std::string& outSuffix) const
+void cmGeneratorTarget::GetFullNameInternal(
+  const std::string& config, cmStateEnums::ArtifactType artifact,
+  std::string& outPrefix, std::string& outBase, std::string& outSuffix) const
 {
 {
   // Use just the target name for non-main target types.
   // Use just the target name for non-main target types.
   if (this->GetType() != cmStateEnums::STATIC_LIBRARY &&
   if (this->GetType() != cmStateEnums::STATIC_LIBRARY &&
@@ -3144,9 +3165,12 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
     return;
     return;
   }
   }
 
 
+  const bool isImportedLibraryArtifact =
+    (artifact == cmStateEnums::ImportLibraryArtifact);
+
   // Return an empty name for the import library if this platform
   // Return an empty name for the import library if this platform
   // does not support import libraries.
   // does not support import libraries.
-  if (implib &&
+  if (isImportedLibraryArtifact &&
       !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
       !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
     outPrefix = "";
     outPrefix = "";
     outBase = "";
     outBase = "";
@@ -3159,14 +3183,16 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
   if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
   if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
       this->GetType() != cmStateEnums::MODULE_LIBRARY &&
       this->GetType() != cmStateEnums::MODULE_LIBRARY &&
       this->GetType() != cmStateEnums::EXECUTABLE) {
       this->GetType() != cmStateEnums::EXECUTABLE) {
-    implib = false;
+    artifact = cmStateEnums::RuntimeBinaryArtifact;
   }
   }
 
 
   // Compute the full name for main target types.
   // Compute the full name for main target types.
-  const char* targetPrefix = (implib ? this->GetProperty("IMPORT_PREFIX")
-                                     : this->GetProperty("PREFIX"));
-  const char* targetSuffix = (implib ? this->GetProperty("IMPORT_SUFFIX")
-                                     : this->GetProperty("SUFFIX"));
+  const char* targetPrefix =
+    (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX")
+                               : this->GetProperty("PREFIX"));
+  const char* targetSuffix =
+    (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX")
+                               : this->GetProperty("SUFFIX"));
   const char* configPostfix = CM_NULLPTR;
   const char* configPostfix = CM_NULLPTR;
   if (!config.empty()) {
   if (!config.empty()) {
     std::string configProp = cmSystemTools::UpperCase(config);
     std::string configProp = cmSystemTools::UpperCase(config);
@@ -3178,8 +3204,8 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
       configPostfix = CM_NULLPTR;
       configPostfix = CM_NULLPTR;
     }
     }
   }
   }
-  const char* prefixVar = this->Target->GetPrefixVariableInternal(implib);
-  const char* suffixVar = this->Target->GetSuffixVariableInternal(implib);
+  const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact);
+  const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact);
 
 
   // Check for language-specific default prefix and suffix.
   // Check for language-specific default prefix and suffix.
   std::string ll = this->GetLinkerLanguage(config);
   std::string ll = this->GetLinkerLanguage(config);
@@ -3223,14 +3249,15 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
   outPrefix = targetPrefix ? targetPrefix : "";
   outPrefix = targetPrefix ? targetPrefix : "";
 
 
   // Append the target name or property-specified name.
   // Append the target name or property-specified name.
-  outBase += this->GetOutputName(config, implib);
+  outBase += this->GetOutputName(config, artifact);
 
 
   // Append the per-configuration postfix.
   // Append the per-configuration postfix.
   outBase += configPostfix ? configPostfix : "";
   outBase += configPostfix ? configPostfix : "";
 
 
   // Name shared libraries with their version number on some platforms.
   // Name shared libraries with their version number on some platforms.
   if (const char* soversion = this->GetProperty("SOVERSION")) {
   if (const char* soversion = this->GetProperty("SOVERSION")) {
-    if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !implib &&
+    if (this->GetType() == cmStateEnums::SHARED_LIBRARY &&
+        !isImportedLibraryArtifact &&
         this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) {
         this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) {
       outBase += "-";
       outBase += "-";
       outBase += soversion;
       outBase += soversion;
@@ -3252,7 +3279,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
   std::string prefix;
   std::string prefix;
   std::string base;
   std::string base;
   std::string suffix;
   std::string suffix;
-  this->GetFullNameInternal(config, false, prefix, base, suffix);
+  this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact,
+                            prefix, base, suffix);
 
 
   std::vector<std::string> props;
   std::vector<std::string> props;
   std::string configUpper = cmSystemTools::UpperCase(config);
   std::string configUpper = cmSystemTools::UpperCase(config);
@@ -4404,26 +4432,31 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
   return iface.Exists ? &iface : CM_NULLPTR;
   return iface.Exists ? &iface : CM_NULLPTR;
 }
 }
 
 
-std::string cmGeneratorTarget::GetDirectory(const std::string& config,
-                                            bool implib) const
+std::string cmGeneratorTarget::GetDirectory(
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   if (this->IsImported()) {
   if (this->IsImported()) {
     // Return the directory from which the target is imported.
     // Return the directory from which the target is imported.
     return cmSystemTools::GetFilenamePath(
     return cmSystemTools::GetFilenamePath(
-      this->Target->ImportedGetFullPath(config, implib));
+      this->Target->ImportedGetFullPath(config, artifact));
   }
   }
   if (OutputInfo const* info = this->GetOutputInfo(config)) {
   if (OutputInfo const* info = this->GetOutputInfo(config)) {
     // Return the directory in which the target will be built.
     // Return the directory in which the target will be built.
-    return implib ? info->ImpDir : info->OutDir;
+    switch (artifact) {
+      case cmStateEnums::RuntimeBinaryArtifact:
+        return info->OutDir;
+      case cmStateEnums::ImportLibraryArtifact:
+        return info->ImpDir;
+    }
   }
   }
   return "";
   return "";
 }
 }
 
 
-bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config,
-                                             bool implib) const
+bool cmGeneratorTarget::UsesDefaultOutputDir(
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   std::string dir;
   std::string dir;
-  return this->ComputeOutputDir(config, implib, dir);
+  return this->ComputeOutputDir(config, artifact, dir);
 }
 }
 
 
 cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
 cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
@@ -4457,8 +4490,10 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
     i = this->OutputInfoMap.insert(entry).first;
     i = this->OutputInfoMap.insert(entry).first;
 
 
     // Compute output directories.
     // Compute output directories.
-    this->ComputeOutputDir(config, false, info.OutDir);
-    this->ComputeOutputDir(config, true, info.ImpDir);
+    this->ComputeOutputDir(config, cmStateEnums::RuntimeBinaryArtifact,
+                           info.OutDir);
+    this->ComputeOutputDir(config, cmStateEnums::ImportLibraryArtifact,
+                           info.ImpDir);
     if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) {
     if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) {
       info.PdbDir = info.OutDir;
       info.PdbDir = info.OutDir;
     }
     }
@@ -4478,14 +4513,15 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
 }
 }
 
 
 bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
 bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
-                                         bool implib, std::string& out) const
+                                         cmStateEnums::ArtifactType artifact,
+                                         std::string& out) const
 {
 {
   bool usesDefaultOutputDir = false;
   bool usesDefaultOutputDir = false;
   std::string conf = config;
   std::string conf = config;
 
 
   // Look for a target property defining the target output directory
   // Look for a target property defining the target output directory
   // based on the target type.
   // based on the target type.
-  std::string targetTypeName = this->GetOutputTargetType(implib);
+  std::string targetTypeName = this->GetOutputTargetType(artifact);
   const char* propertyName = CM_NULLPTR;
   const char* propertyName = CM_NULLPTR;
   std::string propertyNameStr = targetTypeName;
   std::string propertyNameStr = targetTypeName;
   if (!propertyNameStr.empty()) {
   if (!propertyNameStr.empty()) {

+ 26 - 16
Source/cmGeneratorTarget.h

@@ -203,9 +203,12 @@ public:
 
 
   /** Get the full path to the target according to the settings in its
   /** Get the full path to the target according to the settings in its
       makefile and the configuration type.  */
       makefile and the configuration type.  */
-  std::string GetFullPath(const std::string& config = "", bool implib = false,
-                          bool realname = false) const;
-  std::string NormalGetFullPath(const std::string& config, bool implib,
+  std::string GetFullPath(
+    const std::string& config = "",
+    cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact,
+    bool realname = false) const;
+  std::string NormalGetFullPath(const std::string& config,
+                                cmStateEnums::ArtifactType artifact,
                                 bool realname) const;
                                 bool realname) const;
   std::string NormalGetRealName(const std::string& config) const;
   std::string NormalGetRealName(const std::string& config) const;
 
 
@@ -233,7 +236,8 @@ public:
   /** Get the full name of the target according to the settings in its
   /** Get the full name of the target according to the settings in its
       makefile.  */
       makefile.  */
   std::string GetFullName(const std::string& config = "",
   std::string GetFullName(const std::string& config = "",
-                          bool implib = false) const;
+                          cmStateEnums::ArtifactType artifact =
+                            cmStateEnums::RuntimeBinaryArtifact) const;
 
 
   /** @return the Mac framework directory without the base. */
   /** @return the Mac framework directory without the base. */
   std::string GetFrameworkDirectory(const std::string& config,
   std::string GetFrameworkDirectory(const std::string& config,
@@ -278,7 +282,8 @@ public:
   void GetFullNameComponents(std::string& prefix, std::string& base,
   void GetFullNameComponents(std::string& prefix, std::string& base,
                              std::string& suffix,
                              std::string& suffix,
                              const std::string& config = "",
                              const std::string& config = "",
-                             bool implib = false) const;
+                             cmStateEnums::ArtifactType artifact =
+                               cmStateEnums::RuntimeBinaryArtifact) const;
 
 
   /** Append to @a base the bundle directory hierarchy up to a certain @a level
   /** Append to @a base the bundle directory hierarchy up to a certain @a level
    * and return it. */
    * and return it. */
@@ -287,8 +292,8 @@ public:
                                    BundleDirectoryLevel level) const;
                                    BundleDirectoryLevel level) const;
 
 
   /** @return the mac content directory for this target. */
   /** @return the mac content directory for this target. */
-  std::string GetMacContentDirectory(const std::string& config = CM_NULLPTR,
-                                     bool implib = false) const;
+  std::string GetMacContentDirectory(
+    const std::string& config, cmStateEnums::ArtifactType artifact) const;
 
 
   /** @return folder prefix for IDEs. */
   /** @return folder prefix for IDEs. */
   std::string GetEffectiveFolderName() const;
   std::string GetEffectiveFolderName() const;
@@ -355,7 +360,7 @@ public:
     std::vector<cmGeneratorTarget*>& objlibs) const;
     std::vector<cmGeneratorTarget*>& objlibs) const;
 
 
   std::string GetFullNameImported(const std::string& config,
   std::string GetFullNameImported(const std::string& config,
-                                  bool implib) const;
+                                  cmStateEnums::ArtifactType artifact) const;
 
 
   /** Get source files common to all configurations and diagnose cases
   /** Get source files common to all configurations and diagnose cases
       with per-config sources.  Excludes sources added by a TARGET_OBJECTS
       with per-config sources.  Excludes sources added by a TARGET_OBJECTS
@@ -415,7 +420,8 @@ public:
       subdirectory for that configuration.  Otherwise just the canonical
       subdirectory for that configuration.  Otherwise just the canonical
       output directory is given.  */
       output directory is given.  */
   std::string GetDirectory(const std::string& config = "",
   std::string GetDirectory(const std::string& config = "",
-                           bool implib = false) const;
+                           cmStateEnums::ArtifactType artifact =
+                             cmStateEnums::RuntimeBinaryArtifact) const;
 
 
   /** Get the directory in which to place the target compiler .pdb file.
   /** Get the directory in which to place the target compiler .pdb file.
       If the configuration name is given then the generator will add its
       If the configuration name is given then the generator will add its
@@ -429,7 +435,8 @@ public:
 
 
   /** Return whether this target uses the default value for its output
   /** Return whether this target uses the default value for its output
       directory.  */
       directory.  */
-  bool UsesDefaultOutputDir(const std::string& config, bool implib) const;
+  bool UsesDefaultOutputDir(const std::string& config,
+                            cmStateEnums::ArtifactType artifact) const;
 
 
   // Cache target output paths for each configuration.
   // Cache target output paths for each configuration.
   struct OutputInfo
   struct OutputInfo
@@ -470,7 +477,8 @@ public:
   std::string GetCompilePDBPath(const std::string& config = "") const;
   std::string GetCompilePDBPath(const std::string& config = "") const;
 
 
   // Get the target base name.
   // Get the target base name.
-  std::string GetOutputName(const std::string& config, bool implib) const;
+  std::string GetOutputName(const std::string& config,
+                            cmStateEnums::ArtifactType artifact) const;
 
 
   void AddSource(const std::string& src);
   void AddSource(const std::string& src);
   void AddTracedSources(std::vector<std::string> const& srcs);
   void AddTracedSources(std::vector<std::string> const& srcs);
@@ -653,8 +661,9 @@ private:
   mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
   mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
 
 
   std::string GetFullNameInternal(const std::string& config,
   std::string GetFullNameInternal(const std::string& config,
-                                  bool implib) const;
-  void GetFullNameInternal(const std::string& config, bool implib,
+                                  cmStateEnums::ArtifactType artifact) const;
+  void GetFullNameInternal(const std::string& config,
+                           cmStateEnums::ArtifactType artifact,
                            std::string& outPrefix, std::string& outBase,
                            std::string& outPrefix, std::string& outBase,
                            std::string& outSuffix) const;
                            std::string& outSuffix) const;
 
 
@@ -662,7 +671,7 @@ private:
   mutable LinkClosureMapType LinkClosureMap;
   mutable LinkClosureMapType LinkClosureMap;
 
 
   // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
   // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
-  const char* GetOutputTargetType(bool implib) const;
+  const char* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const;
 
 
   void ComputeVersionedName(std::string& vName, std::string const& prefix,
   void ComputeVersionedName(std::string& vName, std::string const& prefix,
                             std::string const& base, std::string const& suffix,
                             std::string const& base, std::string const& suffix,
@@ -788,7 +797,8 @@ private:
 
 
   cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(
   cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(
     const std::string& config, const cmGeneratorTarget* head) const;
     const std::string& config, const cmGeneratorTarget* head) const;
-  bool ComputeOutputDir(const std::string& config, bool implib,
+  bool ComputeOutputDir(const std::string& config,
+                        cmStateEnums::ArtifactType artifact,
                         std::string& out) const;
                         std::string& out) const;
 
 
   typedef std::map<std::string, OutputInfo> OutputInfoMapType;
   typedef std::map<std::string, OutputInfo> OutputInfoMapType;
@@ -800,7 +810,7 @@ private:
   void ComputeModuleDefinitionInfo(std::string const& config,
   void ComputeModuleDefinitionInfo(std::string const& config,
                                    ModuleDefinitionInfo& info) const;
                                    ModuleDefinitionInfo& info) const;
 
 
-  typedef std::pair<std::string, bool> OutputNameKey;
+  typedef std::pair<std::string, cmStateEnums::ArtifactType> OutputNameKey;
   typedef std::map<OutputNameKey, std::string> OutputNameMapType;
   typedef std::map<OutputNameKey, std::string> OutputNameMapType;
   mutable OutputNameMapType OutputNameMap;
   mutable OutputNameMapType OutputNameMap;
   mutable std::set<cmLinkItem> UtilityItems;
   mutable std::set<cmLinkItem> UtilityItems;

+ 2 - 2
Source/cmGlobalNinjaGenerator.cxx

@@ -983,8 +983,8 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs(
     case cmStateEnums::SHARED_LIBRARY:
     case cmStateEnums::SHARED_LIBRARY:
     case cmStateEnums::STATIC_LIBRARY:
     case cmStateEnums::STATIC_LIBRARY:
     case cmStateEnums::MODULE_LIBRARY: {
     case cmStateEnums::MODULE_LIBRARY: {
-      outputs.push_back(this->ConvertToNinjaPath(
-        target->GetFullPath(configName, false, realname)));
+      outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath(
+        configName, cmStateEnums::RuntimeBinaryArtifact, realname)));
       break;
       break;
     }
     }
     case cmStateEnums::OBJECT_LIBRARY:
     case cmStateEnums::OBJECT_LIBRARY:

+ 2 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -1817,7 +1817,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       gtgt->GetType() == cmStateEnums::MODULE_LIBRARY ||
       gtgt->GetType() == cmStateEnums::MODULE_LIBRARY ||
       gtgt->GetType() == cmStateEnums::EXECUTABLE) {
       gtgt->GetType() == cmStateEnums::EXECUTABLE) {
     if (this->XcodeVersion >= 21) {
     if (this->XcodeVersion >= 21) {
-      if (!gtgt->UsesDefaultOutputDir(configName, false)) {
+      if (!gtgt->UsesDefaultOutputDir(configName,
+                                      cmStateEnums::RuntimeBinaryArtifact)) {
         std::string pncdir = gtgt->GetDirectory(configName);
         std::string pncdir = gtgt->GetDirectory(configName);
         buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
         buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
                                     this->CreateString(pncdir));
                                     this->CreateString(pncdir));

+ 4 - 1
Source/cmInstallTargetGenerator.cxx

@@ -103,7 +103,10 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
     fromDirConfig += cmake::GetCMakeFilesDirectory();
     fromDirConfig += cmake::GetCMakeFilesDirectory();
     fromDirConfig += "/CMakeRelink.dir/";
     fromDirConfig += "/CMakeRelink.dir/";
   } else {
   } else {
-    fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary);
+    cmStateEnums::ArtifactType artifact = this->ImportLibrary
+      ? cmStateEnums::ImportLibraryArtifact
+      : cmStateEnums::RuntimeBinaryArtifact;
+    fromDirConfig = this->Target->GetDirectory(config, artifact);
     fromDirConfig += "/";
     fromDirConfig += "/";
   }
   }
 
 

+ 4 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -1133,7 +1133,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
       if (stackVal) {
       if (stackVal) {
         fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
         fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
       }
       }
-      temp = target->GetDirectory(configName, true);
+      temp =
+        target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact);
       temp += "/";
       temp += "/";
       temp += targetNameImport;
       temp += targetNameImport;
       fout << "\t\t\t\tImportLibrary=\""
       fout << "\t\t\t\tImportLibrary=\""
@@ -1231,7 +1232,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
       if (stackVal) {
       if (stackVal) {
         fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
         fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
       }
       }
-      temp = target->GetDirectory(configName, true);
+      temp =
+        target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact);
       temp += "/";
       temp += "/";
       temp += targetNameImport;
       temp += targetNameImport;
       fout << "\t\t\t\tImportLibrary=\""
       fout << "\t\t\t\tImportLibrary=\""

+ 4 - 2
Source/cmLocalVisualStudioGenerator.cxx

@@ -80,8 +80,10 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
       !(isFortran && target->GetType() == cmStateEnums::SHARED_LIBRARY)) {
       !(isFortran && target->GetType() == cmStateEnums::SHARED_LIBRARY)) {
     return pcc;
     return pcc;
   }
   }
-  std::string outDir = target->GetDirectory(config, false);
-  std::string impDir = target->GetDirectory(config, true);
+  std::string outDir =
+    target->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact);
+  std::string impDir =
+    target->GetDirectory(config, cmStateEnums::ImportLibraryArtifact);
   if (impDir == outDir) {
   if (impDir == outDir) {
     return pcc;
     return pcc;
   }
   }

+ 3 - 1
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -21,6 +21,7 @@
 #include "cmState.h"
 #include "cmState.h"
 #include "cmStateDirectory.h"
 #include "cmStateDirectory.h"
 #include "cmStateSnapshot.h"
 #include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmSystemTools.h"
 #include "cm_auto_ptr.hxx"
 #include "cm_auto_ptr.hxx"
 #include "cmake.h"
 #include "cmake.h"
@@ -332,7 +333,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   } else {
   } else {
     cmSystemTools::MakeDirectory(outpath.c_str());
     cmSystemTools::MakeDirectory(outpath.c_str());
     if (!targetNameImport.empty()) {
     if (!targetNameImport.empty()) {
-      outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true);
+      outpathImp = this->GeneratorTarget->GetDirectory(
+        this->ConfigName, cmStateEnums::ImportLibraryArtifact);
       cmSystemTools::MakeDirectory(outpathImp.c_str());
       cmSystemTools::MakeDirectory(outpathImp.c_str());
       outpathImp += "/";
       outpathImp += "/";
     }
     }

+ 2 - 1
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -514,7 +514,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
     cmSystemTools::MakeDirectory(outpath.c_str());
     cmSystemTools::MakeDirectory(outpath.c_str());
     outpath += "/";
     outpath += "/";
     if (!targetNameImport.empty()) {
     if (!targetNameImport.empty()) {
-      outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true);
+      outpathImp = this->GeneratorTarget->GetDirectory(
+        this->ConfigName, cmStateEnums::ImportLibraryArtifact);
       cmSystemTools::MakeDirectory(outpathImp.c_str());
       cmSystemTools::MakeDirectory(outpathImp.c_str());
       outpathImp += "/";
       outpathImp += "/";
     }
     }

+ 2 - 2
Source/cmMakefileTargetGenerator.cxx

@@ -509,8 +509,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
         this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
         this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
         this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
         this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
         this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
         this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
-      targetFullPathReal =
-        this->GeneratorTarget->GetFullPath(this->ConfigName, false, true);
+      targetFullPathReal = this->GeneratorTarget->GetFullPath(
+        this->ConfigName, cmStateEnums::RuntimeBinaryArtifact, true);
       targetFullPathPDB =
       targetFullPathPDB =
         this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
         this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
       targetFullPathPDB += "/";
       targetFullPathPDB += "/";

+ 10 - 14
Source/cmNinjaNormalTargetGenerator.cxx

@@ -491,10 +491,9 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
         cmGeneratorTarget& gt = *this->GetGeneratorTarget();
         cmGeneratorTarget& gt = *this->GetGeneratorTarget();
         const std::string cfgName = this->GetConfigName();
         const std::string cfgName = this->GetConfigName();
         std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
         std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
-        std::string targetOutputReal =
-          this->ConvertToNinjaPath(gt.GetFullPath(cfgName,
-                                                  /*implib=*/false,
-                                                  /*realname=*/true));
+        std::string targetOutputReal = this->ConvertToNinjaPath(
+          gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact,
+                         /*realname=*/true));
         cmakeCommand += targetOutputReal;
         cmakeCommand += targetOutputReal;
         cmakeCommand += " || true";
         cmakeCommand += " || true";
         linkCmds.push_back(cmakeCommand);
         linkCmds.push_back(cmakeCommand);
@@ -616,9 +615,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
   std::string const targetOutputReal = ConvertToNinjaPath(
   std::string const targetOutputReal = ConvertToNinjaPath(
     genTarget.ObjectDirectory + "cmake_device_link" + objExt);
     genTarget.ObjectDirectory + "cmake_device_link" + objExt);
 
 
-  std::string const targetOutputImplib =
-    ConvertToNinjaPath(genTarget.GetFullPath(cfgName,
-                                             /*implib=*/true));
+  std::string const targetOutputImplib = ConvertToNinjaPath(
+    genTarget.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact));
 
 
   this->DeviceLinkObject = targetOutputReal;
   this->DeviceLinkObject = targetOutputReal;
 
 
@@ -788,13 +786,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   cmGeneratorTarget& gt = *this->GetGeneratorTarget();
   cmGeneratorTarget& gt = *this->GetGeneratorTarget();
   const std::string cfgName = this->GetConfigName();
   const std::string cfgName = this->GetConfigName();
   std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
   std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
-  std::string targetOutputReal =
-    ConvertToNinjaPath(gt.GetFullPath(cfgName,
-                                      /*implib=*/false,
-                                      /*realname=*/true));
-  std::string targetOutputImplib =
-    ConvertToNinjaPath(gt.GetFullPath(cfgName,
-                                      /*implib=*/true));
+  std::string targetOutputReal = ConvertToNinjaPath(
+    gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact,
+                   /*realname=*/true));
+  std::string targetOutputImplib = ConvertToNinjaPath(
+    gt.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact));
 
 
   if (gt.IsAppBundleOnApple()) {
   if (gt.IsAppBundleOnApple()) {
     // Create the app bundle
     // Create the app bundle

+ 3 - 2
Source/cmOSXBundleGenerator.cxx

@@ -7,6 +7,7 @@
 #include "cmGeneratorTarget.h"
 #include "cmGeneratorTarget.h"
 #include "cmLocalGenerator.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmMakefile.h"
+#include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cmTarget.h"
 
 
@@ -213,8 +214,8 @@ std::string cmOSXBundleGenerator::InitMacOSXContentDirectory(
 {
 {
   // Construct the full path to the content subdirectory.
   // Construct the full path to the content subdirectory.
 
 
-  std::string macdir = this->GT->GetMacContentDirectory(this->ConfigName,
-                                                        /*implib*/ false);
+  std::string macdir = this->GT->GetMacContentDirectory(
+    this->ConfigName, cmStateEnums::RuntimeBinaryArtifact);
   macdir += "/";
   macdir += "/";
   macdir += pkgloc;
   macdir += pkgloc;
   cmSystemTools::MakeDirectory(macdir.c_str());
   cmSystemTools::MakeDirectory(macdir.c_str());

+ 4 - 2
Source/cmServerProtocol.cxx

@@ -763,9 +763,11 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
 
 
   if (target->HaveWellDefinedOutputFiles()) {
   if (target->HaveWellDefinedOutputFiles()) {
     Json::Value artifacts = Json::arrayValue;
     Json::Value artifacts = Json::arrayValue;
-    artifacts.append(target->GetFullPath(config, false));
+    artifacts.append(
+      target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact));
     if (target->IsDLLPlatform()) {
     if (target->IsDLLPlatform()) {
-      artifacts.append(target->GetFullPath(config, true));
+      artifacts.append(
+        target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact));
       const cmGeneratorTarget::OutputInfo* output =
       const cmGeneratorTarget::OutputInfo* output =
         target->GetOutputInfo(config);
         target->GetOutputInfo(config);
       if (output && !output->PdbDir.empty()) {
       if (output && !output->PdbDir.empty()) {

+ 6 - 0
Source/cmStateTypes.h

@@ -53,6 +53,12 @@ enum CacheEntryType
   STATIC,
   STATIC,
   UNINITIALIZED
   UNINITIALIZED
 };
 };
+
+enum ArtifactType
+{
+  RuntimeBinaryArtifact,
+  ImportLibraryArtifact
+};
 }
 }
 
 
 #endif
 #endif

+ 89 - 53
Source/cmTarget.cxx

@@ -35,7 +35,7 @@ const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>(
 {
 {
   static std::string loc;
   static std::string loc;
   if (tgt->IsImported()) {
   if (tgt->IsImported()) {
-    loc = tgt->ImportedGetFullPath("", false);
+    loc = tgt->ImportedGetFullPath("", cmStateEnums::RuntimeBinaryArtifact);
     return loc.c_str();
     return loc.c_str();
   }
   }
 
 
@@ -54,7 +54,8 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>(
 {
 {
   static std::string loc;
   static std::string loc;
   if (tgt->IsImported()) {
   if (tgt->IsImported()) {
-    loc = tgt->ImportedGetFullPath(config, false);
+    loc =
+      tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
     return loc.c_str();
     return loc.c_str();
   }
   }
 
 
@@ -63,7 +64,7 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>(
     gg->CreateGenerationObjects();
     gg->CreateGenerationObjects();
   }
   }
   cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName());
   cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName());
-  loc = gt->GetFullPath(config, false);
+  loc = gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
   return loc.c_str();
   return loc.c_str();
 }
 }
 
 
@@ -1294,58 +1295,88 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const
   return cmSystemTools::IsOn(this->GetProperty(prop));
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 }
 
 
-const char* cmTarget::GetSuffixVariableInternal(bool implib) const
+const char* cmTarget::GetSuffixVariableInternal(
+  cmStateEnums::ArtifactType artifact) const
 {
 {
   switch (this->GetType()) {
   switch (this->GetType()) {
     case cmStateEnums::STATIC_LIBRARY:
     case cmStateEnums::STATIC_LIBRARY:
       return "CMAKE_STATIC_LIBRARY_SUFFIX";
       return "CMAKE_STATIC_LIBRARY_SUFFIX";
     case cmStateEnums::SHARED_LIBRARY:
     case cmStateEnums::SHARED_LIBRARY:
-      return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
-                     : "CMAKE_SHARED_LIBRARY_SUFFIX");
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          return "CMAKE_SHARED_LIBRARY_SUFFIX";
+        case cmStateEnums::ImportLibraryArtifact:
+          return "CMAKE_IMPORT_LIBRARY_SUFFIX";
+      }
+      break;
     case cmStateEnums::MODULE_LIBRARY:
     case cmStateEnums::MODULE_LIBRARY:
-      return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
-                     : "CMAKE_SHARED_MODULE_SUFFIX");
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          return "CMAKE_SHARED_MODULE_SUFFIX";
+        case cmStateEnums::ImportLibraryArtifact:
+          return "CMAKE_IMPORT_LIBRARY_SUFFIX";
+      }
+      break;
     case cmStateEnums::EXECUTABLE:
     case cmStateEnums::EXECUTABLE:
-      return (implib
-                ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
-                // Android GUI application packages store the native
-                // binary as a shared library.
-                : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
-                     ? "CMAKE_SHARED_LIBRARY_SUFFIX"
-                     : "CMAKE_EXECUTABLE_SUFFIX"));
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          // Android GUI application packages store the native
+          // binary as a shared library.
+          return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
+                    ? "CMAKE_SHARED_LIBRARY_SUFFIX"
+                    : "CMAKE_EXECUTABLE_SUFFIX");
+        case cmStateEnums::ImportLibraryArtifact:
+          return "CMAKE_IMPORT_LIBRARY_SUFFIX";
+      }
+      break;
     default:
     default:
       break;
       break;
   }
   }
   return "";
   return "";
 }
 }
 
 
-const char* cmTarget::GetPrefixVariableInternal(bool implib) const
+const char* cmTarget::GetPrefixVariableInternal(
+  cmStateEnums::ArtifactType artifact) const
 {
 {
   switch (this->GetType()) {
   switch (this->GetType()) {
     case cmStateEnums::STATIC_LIBRARY:
     case cmStateEnums::STATIC_LIBRARY:
       return "CMAKE_STATIC_LIBRARY_PREFIX";
       return "CMAKE_STATIC_LIBRARY_PREFIX";
     case cmStateEnums::SHARED_LIBRARY:
     case cmStateEnums::SHARED_LIBRARY:
-      return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX"
-                     : "CMAKE_SHARED_LIBRARY_PREFIX");
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          return "CMAKE_SHARED_LIBRARY_PREFIX";
+        case cmStateEnums::ImportLibraryArtifact:
+          return "CMAKE_IMPORT_LIBRARY_PREFIX";
+      }
+      break;
     case cmStateEnums::MODULE_LIBRARY:
     case cmStateEnums::MODULE_LIBRARY:
-      return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX"
-                     : "CMAKE_SHARED_MODULE_PREFIX");
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          return "CMAKE_SHARED_MODULE_PREFIX";
+        case cmStateEnums::ImportLibraryArtifact:
+          return "CMAKE_IMPORT_LIBRARY_PREFIX";
+      }
+      break;
     case cmStateEnums::EXECUTABLE:
     case cmStateEnums::EXECUTABLE:
-      return (implib
-                ? "CMAKE_IMPORT_LIBRARY_PREFIX"
-                // Android GUI application packages store the native
-                // binary as a shared library.
-                : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
-                     ? "CMAKE_SHARED_LIBRARY_PREFIX"
-                     : ""));
+      switch (artifact) {
+        case cmStateEnums::RuntimeBinaryArtifact:
+          // Android GUI application packages store the native
+          // binary as a shared library.
+          return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
+                    ? "CMAKE_SHARED_LIBRARY_PREFIX"
+                    : "");
+        case cmStateEnums::ImportLibraryArtifact:
+          return "CMAKE_IMPORT_LIBRARY_PREFIX";
+      }
+      break;
     default:
     default:
       break;
       break;
   }
   }
   return "";
   return "";
 }
 }
 
 
-std::string cmTarget::ImportedGetFullPath(const std::string& config,
-                                          bool pimplib) const
+std::string cmTarget::ImportedGetFullPath(
+  const std::string& config, cmStateEnums::ArtifactType artifact) const
 {
 {
   assert(this->IsImported());
   assert(this->IsImported());
 
 
@@ -1364,32 +1395,37 @@ std::string cmTarget::ImportedGetFullPath(const std::string& config,
 
 
   if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
   if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
       this->GetMappedConfig(desired_config, &loc, &imp, suffix)) {
       this->GetMappedConfig(desired_config, &loc, &imp, suffix)) {
-    if (!pimplib) {
-      if (loc) {
-        result = loc;
-      } else {
-        std::string impProp = "IMPORTED_LOCATION";
-        impProp += suffix;
-        if (const char* config_location = this->GetProperty(impProp)) {
-          result = config_location;
-        } else if (const char* location =
-                     this->GetProperty("IMPORTED_LOCATION")) {
-          result = location;
+    switch (artifact) {
+      case cmStateEnums::RuntimeBinaryArtifact:
+        if (loc) {
+          result = loc;
+        } else {
+          std::string impProp = "IMPORTED_LOCATION";
+          impProp += suffix;
+          if (const char* config_location = this->GetProperty(impProp)) {
+            result = config_location;
+          } else if (const char* location =
+                       this->GetProperty("IMPORTED_LOCATION")) {
+            result = location;
+          }
         }
         }
-      }
-    } else {
-      if (imp) {
-        result = imp;
-      } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
-                 this->IsExecutableWithExports()) {
-        std::string impProp = "IMPORTED_IMPLIB";
-        impProp += suffix;
-        if (const char* config_implib = this->GetProperty(impProp)) {
-          result = config_implib;
-        } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) {
-          result = implib;
+        break;
+
+      case cmStateEnums::ImportLibraryArtifact:
+        if (imp) {
+          result = imp;
+        } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+                   this->IsExecutableWithExports()) {
+          std::string impProp = "IMPORTED_IMPLIB";
+          impProp += suffix;
+          if (const char* config_implib = this->GetProperty(impProp)) {
+            result = config_implib;
+          } else if (const char* implib =
+                       this->GetProperty("IMPORTED_IMPLIB")) {
+            result = implib;
+          }
         }
         }
-      }
+        break;
     }
     }
   }
   }
 
 

+ 5 - 3
Source/cmTarget.h

@@ -267,11 +267,13 @@ public:
   };
   };
 
 
   std::string ImportedGetFullPath(const std::string& config,
   std::string ImportedGetFullPath(const std::string& config,
-                                  bool implib) const;
+                                  cmStateEnums::ArtifactType artifact) const;
 
 
 private:
 private:
-  const char* GetSuffixVariableInternal(bool implib) const;
-  const char* GetPrefixVariableInternal(bool implib) const;
+  const char* GetSuffixVariableInternal(
+    cmStateEnums::ArtifactType artifact) const;
+  const char* GetPrefixVariableInternal(
+    cmStateEnums::ArtifactType artifact) const;
 
 
   // Use a makefile variable to set a default for the given property.
   // Use a makefile variable to set a default for the given property.
   // If the variable is not defined use the given default instead.
   // If the variable is not defined use the given default instead.

+ 4 - 4
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1051,8 +1051,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
 
 
   std::string postfixName = cmSystemTools::UpperCase(config);
   std::string postfixName = cmSystemTools::UpperCase(config);
   postfixName += "_POSTFIX";
   postfixName += "_POSTFIX";
-  std::string assemblyName =
-    this->GeneratorTarget->GetOutputName(config, false);
+  std::string assemblyName = this->GeneratorTarget->GetOutputName(
+    config, cmStateEnums::RuntimeBinaryArtifact);
   if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) {
   if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) {
     assemblyName += postfix;
     assemblyName += postfix;
   }
   }
@@ -3014,8 +3014,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
     std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str());
     std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str());
     pdb += "/";
     pdb += "/";
     pdb += targetNamePDB;
     pdb += targetNamePDB;
-    std::string imLib =
-      this->GeneratorTarget->GetDirectory(config.c_str(), true);
+    std::string imLib = this->GeneratorTarget->GetDirectory(
+      config.c_str(), cmStateEnums::ImportLibraryArtifact);
     imLib += "/";
     imLib += "/";
     imLib += targetNameImport;
     imLib += targetNameImport;