mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 14:19:59 -05:00
Merge topic 'minor-cleanups'
c637e0c5cmMakefile: Return a string from GetDefineFlagsfbc1b75cTest: Remove condition for CMake version no longer supported3d0e95f6cmLocalGenerator: Extract definition retrieval out of loop2a49d86dMakefiles: Inline only use of methodb0301db2Makefiles: Make helper class independent of cmLocalGenerator267e0209cmMakefile: Remove pointless condition009019f2Makefiles: Extract identical code from condition378849f4Makefiles: Replace array access with local variable4a3c49b4Makefiles: Separate two coupled calls
This commit is contained in:
@@ -244,7 +244,7 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
|
||||
flags, this->GeneratorTarget, lang);
|
||||
|
||||
// Append old-style preprocessor definition flags.
|
||||
if (std::string(" ") != std::string(this->Makefile->GetDefineFlags())) {
|
||||
if (this->Makefile->GetDefineFlags() != " ") {
|
||||
this->LocalGenerator->AppendFlags(flags,
|
||||
this->Makefile->GetDefineFlags());
|
||||
}
|
||||
|
||||
@@ -1176,12 +1176,13 @@ void cmLocalGenerator::GetTargetFlags(
|
||||
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) {
|
||||
std::vector<cmSourceFile*> sources;
|
||||
target->GetSourceFiles(sources, buildType);
|
||||
std::string defFlag =
|
||||
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||
for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
|
||||
i != sources.end(); ++i) {
|
||||
cmSourceFile* sf = *i;
|
||||
if (sf->GetExtension() == "def") {
|
||||
linkFlags +=
|
||||
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
||||
linkFlags += defFlag;
|
||||
linkFlags += this->ConvertToOutputFormat(
|
||||
cmSystemTools::CollapseFullPath(sf->GetFullPath()), SHELL);
|
||||
linkFlags += " ";
|
||||
|
||||
@@ -995,16 +995,13 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
|
||||
std::string output;
|
||||
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
||||
if (!outputs.empty()) {
|
||||
output = outputs[0];
|
||||
if (workingDir.empty()) {
|
||||
output = this->ConvertToOutputFormat(
|
||||
this->MaybeConvertToRelativePath(
|
||||
this->GetCurrentBinaryDirectory(), outputs[0]),
|
||||
cmOutputConverter::SHELL);
|
||||
|
||||
} else {
|
||||
output = this->ConvertToOutputFormat(outputs[0],
|
||||
cmOutputConverter::SHELL);
|
||||
output = this->MaybeConvertToRelativePath(
|
||||
this->GetCurrentBinaryDirectory(), output);
|
||||
}
|
||||
output =
|
||||
this->ConvertToOutputFormat(output, cmOutputConverter::SHELL);
|
||||
}
|
||||
vars.Output = output.c_str();
|
||||
|
||||
|
||||
@@ -3970,10 +3970,8 @@ cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(
|
||||
bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var)
|
||||
{
|
||||
// Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
|
||||
if (!var.empty()) {
|
||||
if (const char* val = this->GetDefinition(var)) {
|
||||
return cmSystemTools::IsOn(val);
|
||||
}
|
||||
if (const char* val = this->GetDefinition(var)) {
|
||||
return cmSystemTools::IsOn(val);
|
||||
}
|
||||
// Enable optional policy warnings with --debug-output, --trace,
|
||||
// or --trace-expand.
|
||||
|
||||
+1
-1
@@ -447,7 +447,7 @@ public:
|
||||
/**
|
||||
* Get a list of preprocessor define flags.
|
||||
*/
|
||||
const char* GetDefineFlags() const { return this->DefineFlags.c_str(); }
|
||||
std::string GetDefineFlags() const { return this->DefineFlags; }
|
||||
|
||||
/**
|
||||
* Make sure CMake can write this file
|
||||
|
||||
@@ -1217,21 +1217,16 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
void cmMakefileTargetGenerator::WriteObjectsString(std::string& buildObjs)
|
||||
{
|
||||
std::vector<std::string> objStrings;
|
||||
this->WriteObjectsStrings(objStrings);
|
||||
buildObjs = objStrings[0];
|
||||
}
|
||||
|
||||
class cmMakefileTargetGeneratorObjectStrings
|
||||
{
|
||||
public:
|
||||
cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings,
|
||||
cmLocalUnixMakefileGenerator3* lg,
|
||||
cmOutputConverter* outputConverter,
|
||||
cmState::Directory stateDir,
|
||||
std::string::size_type limit)
|
||||
: Strings(strings)
|
||||
, LocalGenerator(lg)
|
||||
, OutputConverter(outputConverter)
|
||||
, StateDir(stateDir)
|
||||
, LengthLimit(limit)
|
||||
{
|
||||
this->Space = "";
|
||||
@@ -1239,10 +1234,8 @@ public:
|
||||
void Feed(std::string const& obj)
|
||||
{
|
||||
// Construct the name of the next object.
|
||||
this->NextObject = this->LocalGenerator->ConvertToOutputFormat(
|
||||
this->LocalGenerator->MaybeConvertToRelativePath(
|
||||
this->LocalGenerator->GetCurrentBinaryDirectory(), obj),
|
||||
cmOutputConverter::RESPONSE);
|
||||
this->NextObject = this->OutputConverter->ConvertToOutputFormat(
|
||||
this->MaybeConvertToRelativePath(obj), cmOutputConverter::RESPONSE);
|
||||
|
||||
// Roll over to next string if the limit will be exceeded.
|
||||
if (this->LengthLimit != std::string::npos &&
|
||||
@@ -1262,8 +1255,19 @@ public:
|
||||
}
|
||||
void Done() { this->Strings.push_back(this->CurrentString); }
|
||||
private:
|
||||
std::string MaybeConvertToRelativePath(std::string const& obj)
|
||||
{
|
||||
if (!cmOutputConverter::ContainedInDirectory(
|
||||
this->StateDir.GetCurrentBinary(), obj, this->StateDir)) {
|
||||
return obj;
|
||||
}
|
||||
return cmOutputConverter::ForceToRelativePath(
|
||||
this->StateDir.GetCurrentBinary(), obj);
|
||||
}
|
||||
|
||||
std::vector<std::string>& Strings;
|
||||
cmLocalUnixMakefileGenerator3* LocalGenerator;
|
||||
cmOutputConverter* OutputConverter;
|
||||
cmState::Directory StateDir;
|
||||
std::string::size_type LengthLimit;
|
||||
std::string CurrentString;
|
||||
std::string NextObject;
|
||||
@@ -1273,8 +1277,9 @@ private:
|
||||
void cmMakefileTargetGenerator::WriteObjectsStrings(
|
||||
std::vector<std::string>& objStrings, std::string::size_type limit)
|
||||
{
|
||||
cmMakefileTargetGeneratorObjectStrings helper(objStrings,
|
||||
this->LocalGenerator, limit);
|
||||
cmMakefileTargetGeneratorObjectStrings helper(
|
||||
objStrings, this->LocalGenerator,
|
||||
this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit);
|
||||
for (std::vector<std::string>::const_iterator i = this->Objects.begin();
|
||||
i != this->Objects.end(); ++i) {
|
||||
helper.Feed(*i);
|
||||
@@ -1665,7 +1670,9 @@ void cmMakefileTargetGenerator::CreateObjectLists(
|
||||
}
|
||||
} else if (useLinkScript) {
|
||||
if (!useArchiveRules) {
|
||||
this->WriteObjectsString(buildObjs);
|
||||
std::vector<std::string> objStrings;
|
||||
this->WriteObjectsStrings(objStrings);
|
||||
buildObjs = objStrings[0];
|
||||
}
|
||||
} else {
|
||||
buildObjs = "$(";
|
||||
|
||||
@@ -112,7 +112,6 @@ protected:
|
||||
void WriteObjectsVariable(std::string& variableName,
|
||||
std::string& variableNameExternal,
|
||||
bool useWatcomQuote);
|
||||
void WriteObjectsString(std::string& buildObjs);
|
||||
void WriteObjectsStrings(std::vector<std::string>& objStrings,
|
||||
std::string::size_type limit = std::string::npos);
|
||||
|
||||
|
||||
@@ -20,16 +20,9 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND
|
||||
configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY)
|
||||
|
||||
# now set up the test:
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk"
|
||||
CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n"
|
||||
)
|
||||
else()
|
||||
get_target_property(cmakeLocation cmake LOCATION)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk"
|
||||
"CMAKE = \"${cmakeLocation}\"\n"
|
||||
)
|
||||
endif()
|
||||
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk"
|
||||
CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n"
|
||||
)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user