summaryrefslogtreecommitdiffstats
path: root/Source/cmGhsMultiTargetGenerator.cxx
diff options
context:
space:
mode:
authorGeoff Viola <geoffrey.viola@asirobots.com>2016-04-24 19:47:48 (GMT)
committerBrad King <brad.king@kitware.com>2016-04-25 14:46:09 (GMT)
commit1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82 (patch)
tree5b839beb4d5ca5aeaccccd4c42ea623a629e9470 /Source/cmGhsMultiTargetGenerator.cxx
parent657a446175c1b61999a77958c5b7480f8be041a5 (diff)
downloadCMake-1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82.zip
CMake-1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82.tar.gz
CMake-1703a6d2c46cc7981dd80bd18d7c2e82ec5d9f82.tar.bz2
GHS: Fix handling of duplicate source filenames (#16046)
Green Hills MULTI project files must specify explicitly distinct object file names for source files with the same name.
Diffstat (limited to 'Source/cmGhsMultiTargetGenerator.cxx')
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 1f17f8f..12e2eee 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -481,9 +481,46 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
}
}
+std::map<const cmSourceFile *, std::string>
+cmGhsMultiTargetGenerator::GetObjectNames(
+ const std::vector<cmSourceFile *> &objectSources)
+{
+ bool found_duplicate = false;
+ std::set<std::string> filenames;
+ for(std::vector<cmSourceFile *>::const_iterator
+ sf = objectSources.begin(); sf != objectSources.end(); ++sf)
+ {
+ const std::string filename =
+ cmSystemTools::GetFilenameName((*sf)->GetFullPath());
+ const std::string lower_filename = cmSystemTools::LowerCase(filename);
+ if (filenames.end() != filenames.find(lower_filename))
+ {
+ found_duplicate = true;
+ }
+ filenames.insert(lower_filename);
+ }
+
+ std::map<const cmSourceFile *, std::string> objectNames;
+ if (found_duplicate)
+ {
+ for(std::vector<cmSourceFile *>::const_iterator
+ sf = objectSources.begin(); sf != objectSources.end(); ++sf)
+ {
+ std::string full_filename = (*sf)->GetFullPath();
+ cmsys::SystemTools::ReplaceString(full_filename, ":/", "_");
+ cmsys::SystemTools::ReplaceString(full_filename, "/", "_");
+ objectNames[*sf] = full_filename;
+ }
+ }
+
+ return objectNames;
+}
+
void cmGhsMultiTargetGenerator::WriteSources(
std::vector<cmSourceFile *> const &objectSources)
{
+ std::map<const cmSourceFile *, std::string> objectNames =
+ cmGhsMultiTargetGenerator::GetObjectNames(objectSources);
for (std::vector<cmSourceFile *>::const_iterator si = objectSources.begin();
si != objectSources.end(); ++si)
{
@@ -515,6 +552,11 @@ void cmGhsMultiTargetGenerator::WriteSources(
"bsp" != (*si)->GetExtension())
{
this->WriteObjectLangOverride(this->FolderBuildStreams[sgPath], (*si));
+ if (objectNames.end() != objectNames.find(*si))
+ {
+ *this->FolderBuildStreams[sgPath] << " -o \"" <<
+ objectNames.find(*si)->second << ".o\"" << std::endl;
+ }
this->WriteObjectDir(this->FolderBuildStreams[sgPath],
this->AbsBuildFilePath + sgPath);