summaryrefslogtreecommitdiffstats
path: root/Source/cmGhsMultiTargetGenerator.cxx
diff options
context:
space:
mode:
authorFred Baksik <frodak17@gmail.com>2019-01-05 16:01:21 (GMT)
committerFred Baksik <frodak17@gmail.com>2019-01-16 15:41:24 (GMT)
commit2ed2d6b46f9fb8f0742ce60bef16f1d636008136 (patch)
treed38c81c2e4b7bcbf38ddd2cb98eba8f050877a9e /Source/cmGhsMultiTargetGenerator.cxx
parentead7117afda23d7cf0c1466ce5229d06240d3de0 (diff)
downloadCMake-2ed2d6b46f9fb8f0742ce60bef16f1d636008136.zip
CMake-2ed2d6b46f9fb8f0742ce60bef16f1d636008136.tar.gz
CMake-2ed2d6b46f9fb8f0742ce60bef16f1d636008136.tar.bz2
GHS: Place build system outputs per target output directives
-- Set output and object file locations -- Suffixes are no longer being forced but will now follow the target properties By default GHS tools have no suffix for executable files so CMAKE_EXECUTABLE_SUFFIX was changed to meet this behavior -- Remove #if 0 blocked out code; it has been replaced. Forcing the -relprog option has been removed from non-kernel executable targets. The default value of this option (if it is even available) is determined by the tool-chain for the specified target and platform (Some tool-chains default to -locatedprogram). The use of -relprog can have unexpected results as it cannot always produce a fully relocated executable. -- Clarify use of CMAKE_BUILD_TYPE to control build configuration
Diffstat (limited to 'Source/cmGhsMultiTargetGenerator.cxx')
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx83
1 files changed, 41 insertions, 42 deletions
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 0e0607d..7d2af09 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGhsMultiTargetGenerator.h"
+#include "cmComputeLinkInformation.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGhsMultiGenerator.h"
@@ -35,6 +36,15 @@ cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target)
this->AbsBuildFilePath = absPathToRoot + this->RelBuildFilePath;
this->AbsBuildFileName = absPathToRoot + this->RelBuildFileName;
this->AbsOutputFileName = absPathToRoot + this->RelOutputFileName;
+
+ // Store the configuration name that is being used
+ if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
+ // Use the build type given by the user.
+ this->ConfigName = config;
+ } else {
+ // No configuration type given.
+ this->ConfigName.clear();
+ }
}
cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator()
@@ -104,6 +114,13 @@ void cmGhsMultiTargetGenerator::Generate()
// Determine type of target for this project
switch (this->GeneratorTarget->GetType()) {
case cmStateEnums::EXECUTABLE: {
+ // Get the name of the executable to generate.
+ std::string targetName;
+ std::string targetNameImport;
+ std::string targetNamePDB;
+ this->GeneratorTarget->GetExecutableNames(
+ targetName, this->TargetNameReal, targetNameImport, targetNamePDB,
+ this->ConfigName);
if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(
this->GeneratorTarget)) {
this->TagType = GhsMultiGpj::INTERGRITY_APPLICATION;
@@ -113,6 +130,13 @@ void cmGhsMultiTargetGenerator::Generate()
break;
}
case cmStateEnums::STATIC_LIBRARY: {
+ std::string targetName;
+ std::string targetNameSO;
+ std::string targetNameImport;
+ std::string targetNamePDB;
+ this->GeneratorTarget->GetLibraryNames(
+ targetName, targetNameSO, this->TargetNameReal, targetNameImport,
+ targetNamePDB, this->ConfigName);
this->TagType = GhsMultiGpj::LIBRARY;
break;
}
@@ -143,6 +167,7 @@ void cmGhsMultiTargetGenerator::Generate()
default:
return;
}
+
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
this->Name.c_str());
@@ -182,7 +207,7 @@ void cmGhsMultiTargetGenerator::GenerateTarget()
cmGlobalGhsMultiGenerator::WriteDisclaimer(&fout);
bool const notKernel = this->IsNotKernel(config, language);
- this->WriteTypeSpecifics(fout, config, notKernel);
+ this->WriteTargetSpecifics(fout, config, notKernel);
this->SetCompilerFlags(config, language, notKernel);
this->WriteCompilerFlags(fout, config, language);
this->WriteCompilerDefinitions(fout, config, language);
@@ -224,34 +249,22 @@ cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator()
this->LocalGenerator->GetGlobalGenerator());
}
-void cmGhsMultiTargetGenerator::WriteTypeSpecifics(std::ostream& fout,
- const std::string& config,
- bool const notKernel)
+void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout,
+ const std::string& config,
+ bool const notKernel)
{
- std::string outputDir(this->GetOutputDirectory(config));
- std::string outputFilename(this->GetOutputFilename(config));
-
- if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
- std::string const& static_library_suffix =
- this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
- fout << " -o \"" << outputDir << outputFilename << static_library_suffix
- << "\"" << std::endl;
- } else if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
- if (notKernel && !this->IsTargetGroup()) {
- fout << " -relprog" << std::endl;
- }
- if (this->IsTargetGroup()) {
- fout << " -o \"" << outputDir << outputFilename << ".elf\""
- << std::endl;
- fout << " :extraOutputFile=\"" << outputDir << outputFilename
- << ".elf.ael\"" << std::endl;
- } else {
- std::string const executable_suffix =
- this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
- fout << " -o \"" << outputDir << outputFilename << executable_suffix
- << "\"" << std::endl;
- }
- }
+ std::string outpath;
+ std::string rootpath = this->LocalGenerator->GetCurrentBinaryDirectory();
+
+ // set target binary file destination
+ outpath = this->GeneratorTarget->GetDirectory(config);
+ outpath = this->LocalGenerator->ConvertToRelativePath(rootpath, outpath);
+ fout << " :binDirRelative=\"" << outpath << "\"" << std::endl;
+ fout << " -o \"" << this->TargetNameReal << "\"" << std::endl;
+
+ // set target object file destination
+ outpath = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+ fout << " :outputDirRelative=\"" << outpath << "\"" << std::endl;
}
void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
@@ -643,8 +656,6 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
*fout << " -o \"" << objectNames.find(si)->second << "\""
<< std::endl;
}
-
- this->WriteObjectDir(*fout, this->AbsBuildFilePath);
}
}
}
@@ -667,18 +678,6 @@ void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
}
}
-void cmGhsMultiTargetGenerator::WriteObjectDir(std::ostream& fout,
- std::string const& dir)
-{
- std::string workingDir(dir);
- cmSystemTools::ConvertToUnixSlashes(workingDir);
- if (!workingDir.empty()) {
- workingDir += "/";
- }
- workingDir += "Objs";
- fout << " -object_dir=\"" << workingDir << "\"" << std::endl;
-}
-
std::string cmGhsMultiTargetGenerator::GetOutputDirectory(
const std::string& config) const
{