mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 21:00:01 -05:00
Merge topic 'refactor-remove-cmToCStr-function'
3a1e6f5f59remove cmToCStr functiondffa3f485ccmGlobalGenerator::PrintCompilerAdvice: use cmProp as augment062432a6bccmCurlSetCAInfo: use std::string as argument Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !6544
This commit is contained in:
@@ -140,7 +140,7 @@ const char* CCONV cmGetCurrentOutputDirectory(void* arg)
|
||||
const char* CCONV cmGetDefinition(void* arg, const char* def)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return cmToCStr(mf->GetDefinition(def));
|
||||
return mf->GetDefinition(def).GetCStr();
|
||||
}
|
||||
|
||||
int CCONV cmIsOn(void* arg, const char* name)
|
||||
@@ -592,12 +592,12 @@ const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
if (cmSourceFile* rsf = sf->RealSourceFile) {
|
||||
return cmToCStr(rsf->GetProperty(prop));
|
||||
return rsf->GetProperty(prop).GetCStr();
|
||||
}
|
||||
if (!strcmp(prop, "LOCATION")) {
|
||||
return sf->FullPath.c_str();
|
||||
}
|
||||
return cmToCStr(sf->Properties.GetPropertyValue(prop));
|
||||
return sf->Properties.GetPropertyValue(prop).GetCStr();
|
||||
}
|
||||
|
||||
int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
|
||||
|
||||
+3
-3
@@ -31,11 +31,11 @@
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile)
|
||||
std::string cmCurlSetCAInfo(::CURL* curl, const std::string& cafile)
|
||||
{
|
||||
std::string e;
|
||||
if (cafile && *cafile) {
|
||||
::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile);
|
||||
if (!cafile.empty()) {
|
||||
::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile.c_str());
|
||||
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
|
||||
}
|
||||
#ifdef CMAKE_FIND_CAFILE
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <cm3p/curl/curl.h>
|
||||
|
||||
std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = nullptr);
|
||||
std::string cmCurlSetCAInfo(::CURL* curl, const std::string& cafile = {});
|
||||
std::string cmCurlSetNETRCOption(::CURL* curl, const std::string& netrc_level,
|
||||
const std::string& netrc_file);
|
||||
std::string cmCurlFixFileURL(std::string url);
|
||||
|
||||
@@ -1986,7 +1986,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
|
||||
|
||||
// check to see if a CAINFO file has been specified
|
||||
// command arg comes first
|
||||
std::string const& cainfo_err = cmCurlSetCAInfo(curl, cmToCStr(cainfo));
|
||||
std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo);
|
||||
if (!cainfo_err.empty()) {
|
||||
status.SetError(cainfo_err);
|
||||
return false;
|
||||
@@ -2304,7 +2304,7 @@ bool HandleUploadCommand(std::vector<std::string> const& args,
|
||||
|
||||
// check to see if a CAINFO file has been specified
|
||||
// command arg comes first
|
||||
std::string const& cainfo_err = cmCurlSetCAInfo(curl, cmToCStr(cainfo));
|
||||
std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo);
|
||||
if (!cainfo_err.empty()) {
|
||||
status.SetError(cainfo_err);
|
||||
return false;
|
||||
|
||||
@@ -5727,7 +5727,7 @@ const char* getTypedProperty<const char*>(
|
||||
cmProp value = tgt->GetProperty(prop);
|
||||
|
||||
if (genexInterpreter == nullptr) {
|
||||
return cmToCStr(value);
|
||||
return value.GetCStr();
|
||||
}
|
||||
|
||||
return genexInterpreter->Evaluate(value ? *value : "", prop).c_str();
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmGetPropertyCommand.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmInstalledFile.h"
|
||||
@@ -32,10 +34,6 @@ enum OutType
|
||||
OutSet
|
||||
};
|
||||
|
||||
// Implementation of result storage.
|
||||
bool StoreResult(OutType infoType, cmMakefile& makefile,
|
||||
const std::string& variable, const char* value);
|
||||
|
||||
// Implementation of each property type.
|
||||
bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name,
|
||||
OutType infoType, const std::string& variable,
|
||||
@@ -253,8 +251,10 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
|
||||
|
||||
namespace {
|
||||
|
||||
// Implementation of result storage.
|
||||
template <typename ValueType>
|
||||
bool StoreResult(OutType infoType, cmMakefile& makefile,
|
||||
const std::string& variable, const char* value)
|
||||
const std::string& variable, ValueType value)
|
||||
{
|
||||
if (infoType == OutSet) {
|
||||
makefile.AddDefinition(variable, value ? "1" : "0");
|
||||
@@ -268,10 +268,11 @@ bool StoreResult(OutType infoType, cmMakefile& makefile,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template <>
|
||||
bool StoreResult(OutType infoType, cmMakefile& makefile,
|
||||
const std::string& variable, cmProp value)
|
||||
const std::string& variable, std::nullptr_t value)
|
||||
{
|
||||
return StoreResult(infoType, makefile, variable, value.GetCStr());
|
||||
return StoreResult(infoType, makefile, variable, cmProp(value));
|
||||
}
|
||||
|
||||
bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name,
|
||||
|
||||
@@ -838,7 +838,7 @@ void cmGlobalGenerator::EnableLanguage(
|
||||
cmSystemTools::RemoveFile(compilerLangFile);
|
||||
if (!this->CMakeInstance->GetIsInTryCompile()) {
|
||||
this->PrintCompilerAdvice(noCompiler, lang,
|
||||
cmToCStr(mf->GetDefinition(compilerEnv)));
|
||||
mf->GetDefinition(compilerEnv));
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR, noCompiler.str());
|
||||
fatalError = true;
|
||||
}
|
||||
@@ -922,7 +922,7 @@ void cmGlobalGenerator::EnableLanguage(
|
||||
|
||||
void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
|
||||
std::string const& lang,
|
||||
const char* envVar) const
|
||||
cmProp envVar) const
|
||||
{
|
||||
// Subclasses override this method if they do not support this advice.
|
||||
os << "Tell CMake where to find the compiler by setting ";
|
||||
|
||||
@@ -550,7 +550,7 @@ protected:
|
||||
virtual bool CheckLanguages(std::vector<std::string> const& languages,
|
||||
cmMakefile* mf) const;
|
||||
virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
|
||||
const char* envVar) const;
|
||||
cmProp envVar) const;
|
||||
|
||||
virtual bool ComputeTargetDepends();
|
||||
|
||||
|
||||
@@ -39,8 +39,9 @@ void cmGlobalJOMMakefileGenerator::GetDocumentation(
|
||||
entry.Brief = "Generates JOM makefiles.";
|
||||
}
|
||||
|
||||
void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(
|
||||
std::ostream& os, std::string const& lang, const char* envVar) const
|
||||
void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
|
||||
std::string const& lang,
|
||||
cmProp envVar) const
|
||||
{
|
||||
if (lang == "CXX" || lang == "C") {
|
||||
/* clang-format off */
|
||||
|
||||
@@ -50,5 +50,5 @@ protected:
|
||||
|
||||
private:
|
||||
void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
|
||||
const char* envVar) const override;
|
||||
cmProp envVar) const override;
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ void cmGlobalNMakeMakefileGenerator::GetDocumentation(
|
||||
}
|
||||
|
||||
void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(
|
||||
std::ostream& os, std::string const& lang, const char* envVar) const
|
||||
std::ostream& os, std::string const& lang, cmProp envVar) const
|
||||
{
|
||||
if (lang == "CXX" || lang == "C") {
|
||||
/* clang-format off */
|
||||
|
||||
@@ -61,5 +61,5 @@ private:
|
||||
void CheckNMakeFeatures();
|
||||
|
||||
void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
|
||||
const char* envVar) const override;
|
||||
cmProp envVar) const override;
|
||||
};
|
||||
|
||||
@@ -201,7 +201,7 @@ protected:
|
||||
private:
|
||||
virtual std::string GetVSMakeProgram() = 0;
|
||||
void PrintCompilerAdvice(std::ostream&, std::string const&,
|
||||
const char*) const override
|
||||
cmProp) const override
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ private:
|
||||
bool XcodeBuildCommandInitialized;
|
||||
|
||||
void PrintCompilerAdvice(std::ostream&, std::string const&,
|
||||
const char*) const override
|
||||
cmProp) const override
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -856,19 +856,18 @@ std::string cmLocalGenerator::GetIncludeFlags(
|
||||
|
||||
std::string const& includeFlag =
|
||||
this->Makefile->GetSafeDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_", lang));
|
||||
const char* sep = cmToCStr(
|
||||
this->Makefile->GetDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_SEP_", lang)));
|
||||
bool quotePaths = false;
|
||||
if (this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) {
|
||||
quotePaths = true;
|
||||
}
|
||||
std::string sep = " ";
|
||||
bool repeatFlag = true;
|
||||
// should the include flag be repeated like ie. -IA -IB
|
||||
if (!sep) {
|
||||
sep = " ";
|
||||
} else {
|
||||
if (cmProp incSep = this->Makefile->GetDefinition(
|
||||
cmStrCat("CMAKE_INCLUDE_FLAG_SEP_", lang))) {
|
||||
// if there is a separator then the flag is not repeated but is only
|
||||
// given once i.e. -classpath a:b:c
|
||||
sep = incSep;
|
||||
repeatFlag = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2453,7 +2453,7 @@ const char* cmMakefile::GetSONameFlag(const std::string& language) const
|
||||
name += language;
|
||||
}
|
||||
name += "_FLAG";
|
||||
return cmToCStr(this->GetDefinition(name));
|
||||
return this->GetDefinition(name).GetCStr();
|
||||
}
|
||||
|
||||
bool cmMakefile::CanIWriteThisFile(std::string const& fileName) const
|
||||
@@ -2531,7 +2531,7 @@ cmProp cmMakefile::GetDefinition(const std::string& name) const
|
||||
vv->VariableAccessed(name,
|
||||
def ? cmVariableWatch::VARIABLE_READ_ACCESS
|
||||
: cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
|
||||
cmToCStr(def), this);
|
||||
def.GetCStr(), this);
|
||||
|
||||
if (watch_function_executed) {
|
||||
// A callback was executed and may have caused re-allocation of the
|
||||
|
||||
@@ -229,11 +229,3 @@ inline bool operator>=(cmProp l, std::nullptr_t) noexcept
|
||||
{
|
||||
return l.Compare(cmProp{}) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary wrapper
|
||||
*/
|
||||
inline const char* cmToCStr(cmProp p)
|
||||
{
|
||||
return p.GetCStr();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user