2001-06-06 17:58:18 +00:00
|
|
|
/*=========================================================================
|
|
|
|
|
2002-10-23 22:03:27 +00:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
2001-06-06 17:58:18 +00:00
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-10-23 22:03:27 +00:00
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
2001-06-06 17:58:18 +00:00
|
|
|
|
2002-01-21 20:30:43 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
2001-06-06 17:58:18 +00:00
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmEnableTestingCommand.h"
|
|
|
|
|
|
|
|
// we do this in the final pass so that we now the subdirs have all
|
|
|
|
// been defined
|
2003-12-29 21:27:06 +00:00
|
|
|
bool cmEnableTestingCommand::InitialPass(std::vector<std::string> const&)
|
|
|
|
{
|
|
|
|
m_Makefile->AddDefinition("CMAKE_TESTING_ENABLED","1");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-06-06 17:58:18 +00:00
|
|
|
void cmEnableTestingCommand::FinalPass()
|
|
|
|
{
|
|
|
|
// Create a full path filename for output Testfile
|
|
|
|
std::string fname;
|
|
|
|
fname = m_Makefile->GetStartOutputDirectory();
|
|
|
|
fname += "/";
|
2001-06-19 11:41:43 +00:00
|
|
|
fname += "DartTestfile.txt";
|
2001-06-06 17:58:18 +00:00
|
|
|
|
2001-06-07 16:22:16 +00:00
|
|
|
cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory());
|
|
|
|
|
2001-06-06 17:58:18 +00:00
|
|
|
// Open the output Testfile
|
|
|
|
std::ofstream fout(fname.c_str());
|
|
|
|
if (!fout)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Error Writing ", fname.c_str());
|
2004-09-07 20:55:25 +00:00
|
|
|
cmSystemTools::ReportLastSystemError("");
|
2001-06-06 17:58:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fout << "# CMake generated Testfile for " << std::endl
|
|
|
|
<< "#\tSource directory: "
|
|
|
|
<< m_Makefile->GetStartDirectory()
|
|
|
|
<< std::endl
|
|
|
|
<< "#\tBuild directory: " << m_Makefile->GetStartOutputDirectory()
|
|
|
|
<< std::endl
|
|
|
|
<< "# " << std::endl
|
|
|
|
<< "# This file replicates the SUBDIRS() and ADD_TEST() commands from the source"
|
|
|
|
<< std::endl
|
|
|
|
<< "# tree CMakeLists.txt file, skipping any SUBDIRS() or ADD_TEST() commands"
|
|
|
|
<< std::endl
|
|
|
|
<< "# that are excluded by CMake control structures, i.e. IF() commands."
|
|
|
|
<< std::endl
|
2001-06-28 20:45:22 +00:00
|
|
|
<< "#" << std::endl
|
|
|
|
<< "# The next line is critical for Dart to work" << std::endl
|
|
|
|
<< "# Duh :-)" << std::endl << std::endl;
|
2001-06-06 17:58:18 +00:00
|
|
|
|
|
|
|
// write out the subdirs for the current directory
|
|
|
|
if (!m_Makefile->GetSubDirectories().empty())
|
|
|
|
{
|
|
|
|
fout << "SUBDIRS(";
|
2004-03-09 21:28:44 +00:00
|
|
|
const std::vector<std::pair<cmStdString, bool> >& subdirs = m_Makefile->GetSubDirectories();
|
|
|
|
std::vector<std::pair<cmStdString, bool> >::const_iterator i = subdirs.begin();
|
|
|
|
fout << (*i).first.c_str();
|
2001-06-06 17:58:18 +00:00
|
|
|
++i;
|
|
|
|
for(; i != subdirs.end(); ++i)
|
|
|
|
{
|
2004-03-09 21:28:44 +00:00
|
|
|
fout << " " << i->first.c_str();
|
2001-06-06 17:58:18 +00:00
|
|
|
}
|
|
|
|
fout << ")" << std::endl << std::endl;;
|
|
|
|
}
|
|
|
|
fout.close();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|