Bladeren bron

cmExportPackageInfoGenerator: Fix -Wdeprecated-redundant-constexpr-static-def

In commit 3d52d70b84 (export: Add initial CPS support, 2024-07-26) we
added a static definition of a `constexpr` member to help older
AppleClang and SunPro linkers.  This is deprecated by C++17 and Clang
now warns about it, so preserving the approach would require complex
conditions. There is no significant benefit to `constexpr` here, so use
a traditional file-scoped definition instead.
Brad King 1 jaar geleden
bovenliggende
commit
1650683c9d
2 gewijzigde bestanden met toevoegingen van 2 en 4 verwijderingen
  1. 2 2
      Source/cmExportPackageInfoGenerator.cxx
  2. 0 2
      Source/cmExportPackageInfoGenerator.h

+ 2 - 2
Source/cmExportPackageInfoGenerator.cxx

@@ -26,7 +26,7 @@
 #include "cmTarget.h"
 #include "cmValue.h"
 
-constexpr char const* cmExportPackageInfoGenerator::CPS_VERSION_STR;
+static const std::string kCPS_VERSION_STR = "0.12.0";
 
 cmExportPackageInfoGenerator::cmExportPackageInfoGenerator(
   std::string packageName, std::string version, std::string versionCompat,
@@ -102,7 +102,7 @@ Json::Value cmExportPackageInfoGenerator::GeneratePackageInfo() const
   Json::Value package;
 
   package["name"] = this->GetPackageName();
-  package["cps_version"] = this->CPS_VERSION_STR;
+  package["cps_version"] = std::string(kCPS_VERSION_STR);
 
   if (!this->PackageVersion.empty()) {
     package["version"] = this->PackageVersion;

+ 0 - 2
Source/cmExportPackageInfoGenerator.h

@@ -111,6 +111,4 @@ private:
 
   std::map<std::string, std::string> LinkTargets;
   std::set<std::string> Requirements;
-
-  static constexpr char const* CPS_VERSION_STR = "0.12.0";
 };