ENH: ctest now uses CMake global generator to do the build part of build-and-test

This commit is contained in:
Ken Martin 2005-02-22 09:12:10 -05:00
parent 832fa0e609
commit 4d30cb309c
11 changed files with 280 additions and 318 deletions

View File

@ -1733,53 +1733,50 @@ void CMakeStdoutCallback(const char* m, int len, void* s)
out->append(m, len); out->append(m, len);
} }
int cmCTest::RunCMake(std::string* outstring, cmOStringStream &out,
int cmCTest::RunCMakeAndTest(std::string* outstring) std::string &cmakeOutString, std::string &cwd,
{ cmake *cm)
{
unsigned int k; unsigned int k;
std::string cmakeOutString; std::vector<std::string> args;
cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString); args.push_back(m_CMakeSelf);
cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString); args.push_back(m_SourceDir);
cmOStringStream out; if(m_BuildGenerator.size())
cmake cm;
double timeout = m_TimeOut;
// default to the build type of ctest itself
if(m_ConfigType.size() == 0)
{ {
#ifdef CMAKE_INTDIR std::string generator = "-G";
m_ConfigType = CMAKE_INTDIR; generator += m_BuildGenerator;
#endif args.push_back(generator);
}
if ( m_ConfigType.size() > 0 )
{
std::string btype = "-DBUILD_TYPE:STRING=" + m_ConfigType;
args.push_back(btype);
} }
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); for(k=0; k < m_BuildOptions.size(); ++k)
out << "Internal cmake changing into directory: " << m_BinaryDir << "\n";
if (!cmSystemTools::FileIsDirectory(m_BinaryDir.c_str()))
{ {
cmSystemTools::MakeDirectory(m_BinaryDir.c_str()); args.push_back(m_BuildOptions[k]);
} }
cmSystemTools::ChangeDirectory(m_BinaryDir.c_str()); if (cm->Run(args) != 0)
if(!m_BuildNoCMake)
{ {
std::vector<std::string> args; out << "Error: cmake execution failed\n";
args.push_back(m_CMakeSelf); out << cmakeOutString << "\n";
args.push_back(m_SourceDir); // return to the original directory
if(m_BuildGenerator.size()) cmSystemTools::ChangeDirectory(cwd.c_str());
if(outstring)
{ {
std::string generator = "-G"; *outstring = out.str();
generator += m_BuildGenerator;
args.push_back(generator);
} }
if ( m_ConfigType.size() > 0 ) else
{ {
std::string btype = "-DBUILD_TYPE:STRING=" + m_ConfigType; std::cerr << out.str() << "\n";
args.push_back(btype);
} }
return 1;
for(k=0; k < m_BuildOptions.size(); ++k) }
{ // do another config?
args.push_back(m_BuildOptions[k]); if(m_BuildTwoConfig)
} {
if (cm.Run(args) != 0) if (cm->Run(args) != 0)
{ {
out << "Error: cmake execution failed\n"; out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n"; out << cmakeOutString << "\n";
@ -1795,222 +1792,76 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
} }
return 1; return 1;
} }
if(m_BuildTwoConfig) }
{ return 0;
if (cm.Run(args) != 0) }
{
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
// return to the original directory
cmSystemTools::ChangeDirectory(cwd.c_str());
if(outstring)
{
*outstring = out.str();
}
else
{
std::cerr << out.str() << "\n";
}
return 1;
}
}
}
cmSystemTools::SetErrorCallback(0, 0); int cmCTest::RunCMakeAndTest(std::string* outstring)
out << cmakeOutString << "\n"; {
if(m_BuildMakeProgram.size() == 0) unsigned int k;
{ std::string cmakeOutString;
out << "Error: cmake does not have a valid MAKEPROGRAM\n"; cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString);
out << "Did you specify a --build-makeprogram and a --build-generator?\n"; cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString);
if(outstring) cmOStringStream out;
{ double timeout = m_TimeOut;
*outstring = out.str();
}
else
{
std::cerr << out.str() << "\n";
}
return 1;
}
int retVal = 0; int retVal = 0;
std::string makeCommand = cmSystemTools::ConvertToOutputPath(m_BuildMakeProgram.c_str());
std::string lowerCaseCommand = cmSystemTools::LowerCase(makeCommand); // default to the build type of ctest itself
// if msdev is the make program then do the following if(m_ConfigType.size() == 0)
// MSDEV 6.0
if(lowerCaseCommand.find("msdev") != std::string::npos)
{ {
// if there are spaces in the makeCommand, assume a full path #ifdef CMAKE_INTDIR
// and convert it to a path with no spaces in it as the m_ConfigType = CMAKE_INTDIR;
// RunSingleCommand does not like spaces
#if defined(_WIN32) && !defined(__CYGWIN__)
if(makeCommand.find(' ') != std::string::npos)
{
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
}
#endif #endif
makeCommand += " ";
makeCommand += m_BuildProject;
makeCommand += ".dsw /MAKE \"";
if(m_BuildTarget.size())
{
makeCommand += m_BuildTarget;
}
else
{
makeCommand += "ALL_BUILD";
}
makeCommand += " - ";
makeCommand += m_ConfigType;
if(m_BuildNoClean)
{
makeCommand += "\" /BUILD";
}
else
{
makeCommand += "\" /REBUILD";
}
} }
// MSDEV 7.0 .NET
else if (lowerCaseCommand.find("devenv") != std::string::npos)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
if(makeCommand.find(' ') != std::string::npos)
{
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
}
#endif
makeCommand += " ";
makeCommand += m_BuildProject;
makeCommand += ".sln ";
if(m_BuildNoClean)
{
makeCommand += "/build ";
}
else
{
makeCommand += "/rebuild ";
}
makeCommand += m_ConfigType + " /project ";
if(m_BuildTarget.size())
{
makeCommand += m_BuildTarget;
}
else
{
makeCommand += "ALL_BUILD";
}
}
else if (lowerCaseCommand.find("xcode") != std::string::npos)
{
makeCommand += " -project ";
makeCommand += m_BuildProject;
makeCommand += ".xcode";
makeCommand += " build -target ";
if (m_BuildTarget.size())
{
makeCommand += m_BuildTarget;
}
else
{
makeCommand += "ALL_BUILD ";
}
makeCommand += " -buildstyle Development ";
}
else if (lowerCaseCommand.find("make") != std::string::npos)
{
// assume a make sytle program
// clean first
if(!m_BuildNoClean)
{
std::string cleanCommand = makeCommand;
cleanCommand += " clean";
out << "Running make clean command: " << cleanCommand.c_str() << " ...\n";
retVal = 0;
std::string output;
if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), &output, &retVal, 0,
false, timeout) ||
retVal)
{
out << "Error: " << cleanCommand.c_str() << " execution failed\n";
out << output.c_str() << "\n";
// return to the original directory
cmSystemTools::ChangeDirectory(cwd.c_str());
out << "Return value: " << retVal << std::endl;
if(outstring)
{
*outstring = out.str();
}
else
{
std::cerr << out.str() << "\n";
}
return 1;
}
out << output;
}
if(m_BuildTarget.size()) // make sure the binary dir is there
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
out << "Internal cmake changing into directory: " << m_BinaryDir << "\n";
if (!cmSystemTools::FileIsDirectory(m_BinaryDir.c_str()))
{
cmSystemTools::MakeDirectory(m_BinaryDir.c_str());
}
cmSystemTools::ChangeDirectory(m_BinaryDir.c_str());
// should we cmake?
cmake cm;
cm.SetGlobalGenerator(cm.CreateGlobalGenerator(m_BuildGenerator.c_str()));
if(!m_BuildNoCMake)
{
// do the cmake step
if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm))
{ {
makeCommand += " "; return 1;
makeCommand += m_BuildTarget;
} }
} }
// command line make program // do the build
out << "Running make command: " << makeCommand.c_str() << "\n";
retVal = 0;
std::string output; std::string output;
if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), &output, &retVal, 0, false, timeout)) retVal = cm.GetGlobalGenerator()->Build(
{ m_SourceDir.c_str(), m_BinaryDir.c_str(),
out << "Error: " << makeCommand.c_str() << " execution failed\n"; m_BuildProject.c_str(), m_BuildTarget.c_str(),
out << output.c_str() << "\n"; &output, m_BuildMakeProgram.c_str(),
// return to the original directory m_ConfigType.c_str(),!m_BuildNoClean);
cmSystemTools::ChangeDirectory(cwd.c_str());
out << "Return value: " << retVal << std::endl;
if(outstring)
{
*outstring = out.str();
}
else
{
std::cerr << out.str() << "\n";
}
return 1;
}
if ( retVal )
{
if(outstring)
{
*outstring = out.str();
*outstring += "Building of project failed\n";
*outstring += output;
*outstring += "\n";
}
else
{
std::cerr << "Building of project failed\n";
std::cerr << out.str() << output << "\n";
}
// return to the original directory
cmSystemTools::ChangeDirectory(cwd.c_str());
return 1;
}
out << output; out << output;
if(outstring)
if(m_TestCommand.size() == 0)
{ {
if(outstring) *outstring = out.str();
{
*outstring = out.str();
}
else
{
std::cout << out.str() << "\n";
}
return retVal;
} }
// if the build failed then return
if (retVal)
{
return 1;
}
// if not test was specified then we are done
if (!m_TestCommand.size())
{
return 0;
}
// now run the compiled test if we can find it // now run the compiled test if we can find it
std::vector<std::string> attempted; std::vector<std::string> attempted;
std::vector<std::string> failed; std::vector<std::string> failed;

View File

@ -23,6 +23,7 @@
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include <time.h> #include <time.h>
class cmake;
class cmMakefile; class cmMakefile;
class cmCTestGenericHandler; class cmCTestGenericHandler;
class cmGeneratedFileStream; class cmGeneratedFileStream;
@ -279,6 +280,10 @@ private:
///! Run CMake and build a test and then run it as a single test. ///! Run CMake and build a test and then run it as a single test.
int RunCMakeAndTest(std::string* output); int RunCMakeAndTest(std::string* output);
int RunCMake(std::string* outstring, cmOStringStream &out,
std::string &cmakeOutString,
std::string &cwd, cmake *cm);
///! Find the running cmake ///! Find the running cmake
void FindRunningCMake(const char* arg0); void FindRunningCMake(const char* arg0);

View File

@ -637,11 +637,11 @@ void cmGlobalGenerator::LocalGenerate()
delete lg; delete lg;
} }
int cmGlobalGenerator::TryCompile(const char *, const char *bindir, int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
const char *, const char *target, const char *projectName,
std::string *output, cmMakefile*) const char *target,
std::string *output, cmMakefile *mf)
{ {
// now build the test
std::string makeCommand = std::string makeCommand =
m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM"); m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM");
if(makeCommand.size() == 0) if(makeCommand.size() == 0)
@ -650,6 +650,41 @@ int cmGlobalGenerator::TryCompile(const char *, const char *bindir,
"Generator cannot find the appropriate make command."); "Generator cannot find the appropriate make command.");
return 1; return 1;
} }
std::string newTarget;
if (target && strlen(target))
{
newTarget += target;
#if 0
#if defined(_WIN32) || defined(__CYGWIN__)
std::string tmp = target;
// if the target does not already end in . something
// then assume .exe
if(tmp.size() < 4 || tmp[tmp.size()-4] != '.')
{
newTarget += ".exe";
}
#endif // WIN32
#endif
}
const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
return this->Build(srcdir,bindir,projectName,
newTarget.c_str(),
output,makeCommand.c_str(),config,false);
}
int cmGlobalGenerator::Build(
const char *, const char *bindir,
const char *, const char *target,
std::string *output,
const char *makeCommandCSTR,
const char *config,
bool clean)
{
*output += "\nTesting TryCompileWithoutMakefile\n";
// now build the test
std::string makeCommand = makeCommandCSTR;
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
/** /**
@ -664,39 +699,58 @@ int cmGlobalGenerator::TryCompile(const char *, const char *bindir,
{ {
makeCommand += " /NOLOGO "; makeCommand += " /NOLOGO ";
} }
int retVal;
int timeout = cmGlobalGenerator::s_TryCompileTimeout;
bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
cmSystemTools::SetRunCommandHideConsole(true);
// should we do a clean first?
if (clean)
{
std::string cleanCommand = makeCommand + " clean";
if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), output,
&retVal, 0, false, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
cmSystemTools::Error("Generator: execution of make clean failed.");
if (output)
{
*output += "\nGenerator: execution of make clean failed.\n";
}
// return to the original directory
cmSystemTools::ChangeDirectory(cwd.c_str());
return 1;
}
}
// now build // now build
if (target) if (target && strlen(target))
{ {
makeCommand += " "; makeCommand += " ";
makeCommand += target; makeCommand += target;
#if defined(_WIN32) || defined(__CYGWIN__)
std::string tmp = target;
// if the target does not already end in . something
// then assume .exe
if(tmp.size() < 4 || tmp[tmp.size()-4] != '.')
{
makeCommand += ".exe";
}
#endif // WIN32
} }
else else
{ {
makeCommand += " all"; makeCommand += " all";
} }
int retVal;
int timeout = cmGlobalGenerator::s_TryCompileTimeout;
bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
cmSystemTools::SetRunCommandHideConsole(true);
if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output, if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output,
&retVal, 0, false, timeout)) &retVal, 0, false, timeout))
{ {
cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::SetRunCommandHideConsole(hideconsole);
cmSystemTools::Error("Generator: execution of make failed."); cmSystemTools::Error("Generator: execution of make failed.");
if (output)
{
*output += "\nGenerator: execution of make failed.\n";
}
// return to the original directory // return to the original directory
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
return 1; return 1;
} }
cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::SetRunCommandHideConsole(hideconsole);
// The SGI MipsPro 7.3 compiler does not return an error code when // The SGI MipsPro 7.3 compiler does not return an error code when

View File

@ -93,6 +93,19 @@ public:
const char *projectName, const char *targetName, const char *projectName, const char *targetName,
std::string *output, cmMakefile* mf); std::string *output, cmMakefile* mf);
/**
* Build a file given the following information. This is a more direct call
* that is used by both CTest and TryCompile. If target name is NULL or
* empty then all is assumed. clean indicates if a "make clean" should be
* done first.
*/
virtual int Build(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName,
std::string *output,
const char *makeProgram, const char *config,
bool clean);
///! Set the CMake instance ///! Set the CMake instance
void SetCMakeInstance(cmake *cm) { void SetCMakeInstance(cmake *cm) {
this->m_CMakeInstance = cm; }; this->m_CMakeInstance = cm; };

View File

@ -67,21 +67,23 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf)
} }
} }
int cmGlobalVisualStudio6Generator::TryCompile(const char *, int cmGlobalVisualStudio6Generator::Build(
const char *bindir, const char *,
const char *projectName, const char *bindir,
const char *targetName, const char *projectName,
std::string *output, const char *targetName,
cmMakefile* mf) std::string *output,
const char *makeCommandCSTR,
const char *config,
bool clean)
{ {
// now build the test // now build the test
std::string makeCommand =
m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM");
std::vector<std::string> mp; std::vector<std::string> mp;
mp.push_back("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup;VsCommonDir]/MSDev98/Bin"); mp.push_back("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup;VsCommonDir]/MSDev98/Bin");
cmSystemTools::ExpandRegistryValues(mp[0]); cmSystemTools::ExpandRegistryValues(mp[0]);
std::string originalCommand = makeCommand; std::string originalCommand = makeCommandCSTR;
makeCommand = cmSystemTools::FindProgram(makeCommand.c_str(), mp); std::string makeCommand =
cmSystemTools::FindProgram(makeCommandCSTR, mp);
if(makeCommand.size() == 0) if(makeCommand.size() == 0)
{ {
std::string e = "Generator cannot find Visual Studio 6 msdev program \""; std::string e = "Generator cannot find Visual Studio 6 msdev program \"";
@ -119,7 +121,7 @@ int cmGlobalVisualStudio6Generator::TryCompile(const char *,
makeCommand += "ALL_BUILD"; makeCommand += "ALL_BUILD";
} }
makeCommand += " - "; makeCommand += " - ";
if(const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION")) if(config)
{ {
makeCommand += config; makeCommand += config;
} }
@ -127,7 +129,14 @@ int cmGlobalVisualStudio6Generator::TryCompile(const char *,
{ {
makeCommand += "Debug"; makeCommand += "Debug";
} }
makeCommand += "\""; if(clean)
{
makeCommand += "\" /REBUILD";
}
else
{
makeCommand += "\" /BUILD";
}
int retVal; int retVal;
int timeout = cmGlobalGenerator::s_TryCompileTimeout; int timeout = cmGlobalGenerator::s_TryCompileTimeout;
if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output, if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output,

View File

@ -47,14 +47,18 @@ public:
* Try to determine system infomation such as shared library * Try to determine system infomation such as shared library
* extension, pthreads, byte order etc. * extension, pthreads, byte order etc.
*/ */
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *); virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *);
/** /**
* Try running cmake and building a file. This is used for dynalically * Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.
*/ */
virtual int TryCompile(const char *srcdir, const char *bindir, virtual int Build(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName, const char *projectName, const char *targetName,
std::string *output, cmMakefile* mf); std::string *output,
const char *makeProgram,
const char *config, bool clean);
/** /**
* Generate the all required files for building this project/tree. This * Generate the all required files for building this project/tree. This

View File

@ -43,23 +43,19 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(std::vector<std::string>cons
this->cmGlobalGenerator::EnableLanguage(lang, mf); this->cmGlobalGenerator::EnableLanguage(lang, mf);
} }
int cmGlobalVisualStudio7Generator::TryCompile(const char *, int cmGlobalVisualStudio7Generator::Build(
const char *bindir, const char *,
const char *projectName, const char *bindir,
const char *targetName, const char *projectName,
std::string *output, const char *targetName,
cmMakefile* mf) std::string *output,
const char *makeCommandCSTR,
const char *config,
bool clean)
{ {
// now build the test // now build the test
std::string makeCommand = std::string makeCommand =
m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM"); cmSystemTools::ConvertToOutputPath(makeCommandCSTR);
if(makeCommand.size() == 0)
{
cmSystemTools::Error(
"Generator cannot find the appropriate make command.");
return 1;
}
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
std::string lowerCaseCommand = makeCommand; std::string lowerCaseCommand = makeCommand;
cmSystemTools::LowerCase(lowerCaseCommand); cmSystemTools::LowerCase(lowerCaseCommand);
@ -80,8 +76,17 @@ int cmGlobalVisualStudio7Generator::TryCompile(const char *,
#endif #endif
makeCommand += " "; makeCommand += " ";
makeCommand += projectName; makeCommand += projectName;
makeCommand += ".sln /build "; makeCommand += ".sln ";
if(const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION")) if(clean)
{
makeCommand += "/rebuild ";
}
else
{
makeCommand += "/build ";
}
if(config && strlen(config))
{ {
makeCommand += config; makeCommand += config;
} }
@ -90,7 +95,8 @@ int cmGlobalVisualStudio7Generator::TryCompile(const char *,
makeCommand += "Debug"; makeCommand += "Debug";
} }
makeCommand += " /project "; makeCommand += " /project ";
if (targetName)
if (targetName && strlen(targetName))
{ {
makeCommand += targetName; makeCommand += targetName;
} }
@ -109,6 +115,7 @@ int cmGlobalVisualStudio7Generator::TryCompile(const char *,
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
return 1; return 1;
} }
*output += makeCommand;
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
return retVal; return retVal;
} }

View File

@ -53,9 +53,11 @@ public:
* Try running cmake and building a file. This is used for dynalically * Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.
*/ */
virtual int TryCompile(const char *srcdir, const char *bindir, virtual int Build(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName, const char *projectName, const char *targetName,
std::string *output, cmMakefile* mf); std::string *output,
const char *makeProgram,
const char *config, bool clean);
/** /**
* Generate the all required files for building this project/tree. This * Generate the all required files for building this project/tree. This

View File

@ -76,23 +76,25 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int cmGlobalXCodeGenerator::TryCompile(const char *, int cmGlobalXCodeGenerator::Build(
const char * bindir, const char *,
const char * projectName, const char *bindir,
const char * targetName, const char *projectName,
std::string * output, const char *targetName,
cmMakefile*) std::string *output,
const char *makeCommandCSTR,
const char *,
bool )
{ {
// now build the test // now build the test
std::string makeCommand = if(makeCommandCSTR == 0 || !strlen(makeCommandCSTR))
m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM");
if(makeCommand.size() == 0)
{ {
cmSystemTools::Error( cmSystemTools::Error(
"Generator cannot find the appropriate make command."); "Generator cannot find the appropriate make command.");
return 1; return 1;
} }
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); std::string makeCommand =
cmSystemTools::ConvertToOutputPath(makeCommandCSTR);
std::string lowerCaseCommand = makeCommand; std::string lowerCaseCommand = makeCommand;
cmSystemTools::LowerCase(lowerCaseCommand); cmSystemTools::LowerCase(lowerCaseCommand);

View File

@ -55,9 +55,11 @@ public:
* Try running cmake and building a file. This is used for dynalically * Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.
*/ */
virtual int TryCompile(const char *srcdir, const char *bindir, virtual int Build(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName, const char *projectName, const char *targetName,
std::string *output, cmMakefile* mf); std::string *output,
const char *makeProgram,
const char *config, bool clean);
/** /**
* Generate the all required files for building this project/tree. This * Generate the all required files for building this project/tree. This

View File

@ -100,18 +100,25 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
"When both -R and -I are specified by default the intersection of " "When both -R and -I are specified by default the intersection of "
"tests are run. By specifying -U the union of tests is run instead."}, "tests are run. By specifying -U the union of tests is run instead."},
{"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.", {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.",
"This option causes ctest to run tests in either an interactive mode or a non-interactive mode. "
"On Windows this means that in non-interactive mode, all system debug pop up windows are blocked. " "This option causes ctest to run tests in either an interactive mode or "
"In dashboard mode (Experimental, Nightly, Continuous), the default is non-interactive. " "a non-interactive mode. On Windows this means that in non-interactive "
"When just running tests not for a dashboard the default is to allow popups and interactive " "mode, all system debug pop up windows are blocked. In dashboard mode "
"(Experimental, Nightly, Continuous), the default is non-interactive. "
"When just running tests not for a dashboard the default is to allow "
"popups and interactive "
"debugging."}, "debugging."},
{"--build-and-test", "Build and run a test.", {"--build-and-test", "Configure, build and run a test.",
"This option allows a test to be compiled and then run. " "This option tells ctest to configure (i.e. run cmake on), build, and or "
"CMake is run on the source tree and then based on the generator the build is run. " "execute a test. The configure and test steps are optional. The arguments "
"The arguments to this command line are the source and binary directories. " "to this command line are the source and binary directories. By default "
"Other options that affect this mode are --build-target --build-nocmake, --build-run-dir, " "this will run CMake on the Source/Bin directories specified unless "
"--build-two-config, --build-exe-dir, --build-generator, --build-project," "--build-nocmake is specified. Both --build-makeprogram and "
"--build-makeprogram " "--build-generator MUST be provided to use --built-and-test. If "
"--test-command is specified then that will be run after the build is "
"complete. Other options that affect this mode are --build-target "
"--build-nocmake, --build-run-dir, "
"--build-two-config, --build-exe-dir, --build-project,"
"--build-noclean, --build-options"}, "--build-noclean, --build-options"},
{"--build-target", "Specify a specific target to build.", {"--build-target", "Specify a specific target to build.",
"This option goes with the --build-and-test option, if left out the all target is built." }, "This option goes with the --build-and-test option, if left out the all target is built." },
@ -126,6 +133,7 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
{"--build-makeprogram", "Specify the make program to use.", "" }, {"--build-makeprogram", "Specify the make program to use.", "" },
{"--build-noclean", "Skip the make clean step.", "" }, {"--build-noclean", "Skip the make clean step.", "" },
{"--build-options", "Add extra options to the build step.", "" }, {"--build-options", "Add extra options to the build step.", "" },
{"--test-command", "The test to run with the --build-and-test option.", "" },
{"--tomorrow-tag", "Nightly or experimental starts with next day tag.", {"--tomorrow-tag", "Nightly or experimental starts with next day tag.",
"This is useful if the build will not finish in one day." }, "This is useful if the build will not finish in one day." },
{0,0,0} {0,0,0}
@ -191,7 +199,12 @@ int main (int argc, char *argv[])
args.push_back(argv[i]); args.push_back(argv[i]);
} }
// run ctest // run ctest
int res = inst.Run(args); std::string output;
int res = inst.Run(args,&output);
if (res)
{
std::cout << output;
}
cmListFileCache::ClearCache(); cmListFileCache::ClearCache();
return res; return res;