summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGhsMultiGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-03-20 13:43:14 (GMT)
committerBrad King <brad.king@kitware.com>2019-03-20 13:48:29 (GMT)
commitf7dca1fc97c08146da33a2d6a3ba22ad8e08d94a (patch)
tree81852e188c9f6b4aa08eb118e3aca4e0f495e66f /Source/cmGlobalGhsMultiGenerator.cxx
parent41d796c09be11da2284182e7da7f79940e86e07b (diff)
downloadCMake-f7dca1fc97c08146da33a2d6a3ba22ad8e08d94a.zip
CMake-f7dca1fc97c08146da33a2d6a3ba22ad8e08d94a.tar.gz
CMake-f7dca1fc97c08146da33a2d6a3ba22ad8e08d94a.tar.bz2
GHS: Fix include-what-you-use and clang-tidy diagnostics
We will soon build GHS sources on Linux where we run these lints.
Diffstat (limited to 'Source/cmGlobalGhsMultiGenerator.cxx')
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx55
1 files changed, 31 insertions, 24 deletions
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 4f1d06a..dd2e100 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -2,19 +2,25 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalGhsMultiGenerator.h"
-#include "cmsys/SystemTools.hxx"
-
-#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
-#include "cmGhsMultiTargetGenerator.h"
+#include "cmGhsMultiGpj.h"
+#include "cmLocalGenerator.h"
#include "cmLocalGhsMultiGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmStateTypes.h"
+#include "cmSystemTools.h"
#include "cmVersion.h"
#include "cmake.h"
+#include <algorithm>
+#include <map>
+#include <ostream>
+#include <string.h>
+#include <utility>
+
const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj";
const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild.exe";
const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs";
@@ -25,9 +31,7 @@ cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
cm->GetState()->SetGhsMultiIDE(true);
}
-cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
-{
-}
+cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() = default;
cmLocalGenerator* cmGlobalGhsMultiGenerator::CreateLocalGenerator(
cmMakefile* mf)
@@ -64,7 +68,8 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
/* no toolset was found */
if (tsp.empty()) {
return false;
- } else if (ts.empty()) {
+ }
+ if (ts.empty()) {
std::string message;
message =
"Green Hills MULTI: -T <toolset> not specified; defaulting to \"";
@@ -86,7 +91,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
const char* prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM");
/* check if the toolset changed from last generate */
- if (prevTool != NULL && (gbuild != prevTool)) {
+ if (prevTool != nullptr && (gbuild != prevTool)) {
std::string message = "toolset build tool: ";
message += gbuild;
message += "\nDoes not match the previously used build tool: ";
@@ -95,13 +100,12 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
"directory or choose a different binary directory.";
cmSystemTools::Error(message);
return false;
- } else {
- /* store the toolset that is being used for this build */
- mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(),
- "build program to use", cmStateEnums::INTERNAL,
- true);
}
+ /* store the toolset that is being used for this build */
+ mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(),
+ "build program to use", cmStateEnums::INTERNAL, true);
+
mf->AddDefinition("CMAKE_SYSTEM_VERSION", tsp.c_str());
return true;
@@ -110,7 +114,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
cmMakefile* mf)
{
- if (p == "") {
+ if (p.empty()) {
cmSystemTools::Message(
"Green Hills MULTI: -A <arch> not specified; defaulting to \"arm\"");
std::string arch = "arm";
@@ -202,7 +206,7 @@ void cmGlobalGhsMultiGenerator::WriteFileHeader(std::ostream& fout)
fout << "#!gbuild" << std::endl;
fout << "#" << std::endl
<< "# CMAKE generated file: DO NOT EDIT!" << std::endl
- << "# Generated by \"" << this->GetActualName() << "\""
+ << "# Generated by \"" << GetActualName() << "\""
<< " Generator, CMake Version " << cmVersion::GetMajorVersion() << "."
<< cmVersion::GetMinorVersion() << std::endl
<< "#" << std::endl
@@ -297,7 +301,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(
if (projName && projType) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
- dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
+ dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir);
if (dir == ".") {
dir.clear();
} else {
@@ -320,7 +324,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(
fname += "REF";
fname += FILE_EXTENSION;
- cmGeneratedFileStream fref(fname.c_str());
+ cmGeneratedFileStream fref(fname);
fref.SetCopyIfDifferent(true);
this->WriteFileHeader(fref);
@@ -361,7 +365,7 @@ void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
fname += ".top";
fname += FILE_EXTENSION;
- cmGeneratedFileStream fout(fname.c_str());
+ cmGeneratedFileStream fout(fname);
fout.SetCopyIfDifferent(true);
this->WriteTopLevelProject(fout, root, generators);
@@ -377,9 +381,12 @@ cmGlobalGhsMultiGenerator::GenerateBuildCommand(
std::vector<std::string> const& makeOptions)
{
GeneratedMakeCommand makeCommand = {};
- const char* gbuild =
- this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
- makeCommand.Add(this->SelectMakeProgram(makeProgram, (std::string)gbuild));
+ std::string gbuild;
+ if (const char* gbuildCached =
+ this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM")) {
+ gbuild = gbuildCached;
+ }
+ makeCommand.Add(this->SelectMakeProgram(makeProgram, gbuild));
if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
makeCommand.Add("-parallel");
@@ -425,7 +432,7 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout)
{
char const* ghsGpjMacros =
this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS");
- if (NULL != ghsGpjMacros) {
+ if (nullptr != ghsGpjMacros) {
std::vector<std::string> expandedList;
cmSystemTools::ExpandListArgument(std::string(ghsGpjMacros), expandedList);
for (std::string const& arg : expandedList) {
@@ -458,7 +465,7 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(std::ostream& fout)
char const* const customization =
this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");
- if (NULL != customization && strlen(customization) > 0) {
+ if (nullptr != customization && strlen(customization) > 0) {
fout << "customization=" << trimQuotes(customization) << std::endl;
this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION");
}