summaryrefslogtreecommitdiff
path: root/Source/CTest/cmCTestLaunch.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-02-12 13:00:22 -0500
committerBrad King <brad.king@kitware.com>2009-02-12 13:00:22 -0500
commit7435355ec8ca10d3d6ef07d975e1f0d9a60b681d (patch)
treec9474211de01f33a296ebea49eb27ab665d02629 /Source/CTest/cmCTestLaunch.cxx
parent4f369610f58c165fbf80ab75a93d45a1d9af6362 (diff)
downloadcmake-7435355ec8ca10d3d6ef07d975e1f0d9a60b681d.tar.gz
ENH: Report file names relative to source dir
This teaches cmCTestLaunch to report source files that lie under the top source directory relative to the top.
Diffstat (limited to 'Source/CTest/cmCTestLaunch.cxx')
-rw-r--r--Source/CTest/cmCTestLaunch.cxx39
1 files changed, 38 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index e68f5243bb..1f99aaa4de 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -292,6 +292,7 @@ int cmCTestLaunch::Run()
return this->ExitCode;
}
+ this->LoadConfig();
this->WriteXML();
return this->ExitCode;
@@ -414,8 +415,21 @@ void cmCTestLaunch::WriteXMLAction(std::ostream& fxml)
// SourceFile
if(!this->OptionSource.empty())
{
+ std::string source = this->OptionSource;
+ cmSystemTools::ConvertToUnixSlashes(source);
+
+ // If file is in source tree use its relative location.
+ if(cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
+ cmSystemTools::FileIsFullPath(source.c_str()) &&
+ cmSystemTools::IsSubDirectory(source.c_str(),
+ this->SourceDir.c_str()))
+ {
+ source = cmSystemTools::RelativePath(this->SourceDir.c_str(),
+ source.c_str());
+ }
+
fxml << "\t\t\t<SourceFile>"
- << cmXMLSafe(this->OptionSource)
+ << cmXMLSafe(source)
<< "</SourceFile>\n";
}
@@ -678,3 +692,26 @@ int cmCTestLaunch::Main(int argc, const char* const argv[])
cmCTestLaunch self(argc, argv);
return self.Run();
}
+
+//----------------------------------------------------------------------------
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmake.h"
+#include <cmsys/auto_ptr.hxx>
+void cmCTestLaunch::LoadConfig()
+{
+ cmake cm;
+ cmGlobalGenerator gg;
+ gg.SetCMakeInstance(&cm);
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
+ cmMakefile* mf = lg->GetMakefile();
+ std::string fname = this->LogDir;
+ fname += "CTestLaunchConfig.cmake";
+ if(cmSystemTools::FileExists(fname.c_str()) &&
+ mf->ReadListFile(0, fname.c_str()))
+ {
+ this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
+ cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
+ }
+}