cmCPackGenerator: Add option to FindTemplate to use alternate builtin path

This commit is contained in:
Brad King
2024-03-06 16:00:11 -05:00
parent 4d661e3a92
commit 438809d3ba
2 changed files with 11 additions and 5 deletions

View File

@@ -7,6 +7,8 @@
#include <memory>
#include <utility>
#include <cmext/string_view>
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx"
@@ -1315,17 +1317,17 @@ const char* cmCPackGenerator::GetPackagingInstallPrefix()
return this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX")->c_str();
}
std::string cmCPackGenerator::FindTemplate(const char* name)
std::string cmCPackGenerator::FindTemplate(cm::string_view name,
cm::optional<cm::string_view> alt)
{
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Look for template: " << (name ? name : "(NULL)")
<< std::endl);
"Look for template: " << name << std::endl);
// Search CMAKE_MODULE_PATH for a custom template.
std::string ffile = this->MakefileMap->GetModulesFile(name);
if (ffile.empty()) {
// Fall back to our internal builtin default.
ffile = cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/Internal/CPack/",
name);
alt ? *alt : ""_s, name);
cmSystemTools::ConvertToUnixSlashes(ffile);
if (!cmSystemTools::FileExists(ffile)) {
ffile.clear();

View File

@@ -9,6 +9,9 @@
#include <string>
#include <vector>
#include <cm/optional>
#include <cm/string_view>
#include "cm_sys_stat.h"
#include "cmCPackComponentGroup.h"
@@ -179,7 +182,8 @@ protected:
virtual const char* GetInstallPath();
virtual const char* GetPackagingInstallPrefix();
virtual std::string FindTemplate(const char* name);
std::string FindTemplate(cm::string_view name,
cm::optional<cm::string_view> alt = cm::nullopt);
virtual bool ConfigureFile(const std::string& inName,
const std::string& outName,
bool copyOnly = false);