diff options
author | Brad King <brad.king@kitware.com> | 2019-03-22 13:22:28 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-22 13:22:44 (GMT) |
commit | 89abbdd8c8db5bf587373f2a00f6a816eddd8496 (patch) | |
tree | 815aaa6b4a54b6782bfb30550a20cfa6e4ee8ccb /Source/cmGlobalGhsMultiGenerator.cxx | |
parent | 4e47e9967aa9d4cd76375468e3b175cd313f3877 (diff) | |
parent | 2c43fb5be345b75d12bba227979efd74b810b49a (diff) | |
download | CMake-89abbdd8c8db5bf587373f2a00f6a816eddd8496.zip CMake-89abbdd8c8db5bf587373f2a00f6a816eddd8496.tar.gz CMake-89abbdd8c8db5bf587373f2a00f6a816eddd8496.tar.bz2 |
Merge topic 'ghs-linux'
2c43fb5be3 FindThreads: Fix pthread library check in GHS Multi Generator
0404efe786 GHS: Add support for GHS Multi Generator in Linux
2060a1445c Tests: Fix file name case in GHS object library test
ddad70c8a4 Tests: Run GHS tests in a separate ctest process
f7dca1fc97 GHS: Fix include-what-you-use and clang-tidy diagnostics
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3006
Diffstat (limited to 'Source/cmGlobalGhsMultiGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGhsMultiGenerator.cxx | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index dba9afa..e6a1d78 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -2,22 +2,33 @@ 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"; +#ifdef __linux__ +const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild"; +const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "/usr/ghs"; +#elif defined(_WIN32) const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild.exe"; const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs"; +#endif cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm) : cmGlobalGenerator(cm) @@ -25,9 +36,7 @@ cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm) cm->GetState()->SetGhsMultiIDE(true); } -cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() -{ -} +cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() = default; cmLocalGenerator* cmGlobalGhsMultiGenerator::CreateLocalGenerator( cmMakefile* mf) @@ -64,7 +73,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 +96,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 +105,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 +119,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"; @@ -201,7 +210,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 @@ -296,7 +305,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 { @@ -319,7 +328,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects( fname += "REF"; fname += FILE_EXTENSION; - cmGeneratedFileStream fref(fname.c_str()); + cmGeneratedFileStream fref(fname); fref.SetCopyIfDifferent(true); this->WriteFileHeader(fref); @@ -360,7 +369,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); @@ -376,9 +385,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"); @@ -424,7 +436,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) { @@ -457,7 +469,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"); } |