ENH: run cmake from cmaketest

This commit is contained in:
Bill Hoffman 2001-08-29 15:57:57 -04:00
parent 222199b3cd
commit 97dc84a613
2 changed files with 25 additions and 14 deletions

View File

@ -132,7 +132,10 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args)
// Find our own executable. // Find our own executable.
std::string cMakeSelf = args[0]; std::string cMakeSelf = args[0];
cmSystemTools::ConvertToUnixSlashes(cMakeSelf); cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str()); if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
{
cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
}
if(!cmSystemTools::FileExists(cMakeSelf.c_str())) if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
{ {
#ifdef CMAKE_BUILD_DIR #ifdef CMAKE_BUILD_DIR
@ -242,7 +245,6 @@ int cmake::Generate(const std::vector<std::string>& args, bool buildMakefiles)
return -1; return -1;
} }
} }
// Create a makefile // Create a makefile
cmMakefile mf; cmMakefile mf;

View File

@ -1,5 +1,7 @@
#include "cmaketest.h" #include "cmaketest.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmake.h"
#include "cmListFileCache.h"
// this is a test driver program for cmake. // this is a test driver program for cmake.
int main (int argc, char *argv[]) int main (int argc, char *argv[])
@ -9,7 +11,6 @@ int main (int argc, char *argv[])
std::cerr << "Usage: " << argv[0] << " test-src-dir test-bin-dir test-executable\n"; std::cerr << "Usage: " << argv[0] << " test-src-dir test-bin-dir test-executable\n";
return 1; return 1;
} }
// does the directory exist ? // does the directory exist ?
if (!cmSystemTools::FileIsDirectory(argv[2])) if (!cmSystemTools::FileIsDirectory(argv[2]))
{ {
@ -30,26 +31,34 @@ int main (int argc, char *argv[])
std::string output; std::string output;
// change to the tests directory and run cmake // change to the tests directory and run cmake
// use the cmake object instead of calling cmake
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(binaryDirectory); cmSystemTools::ChangeDirectory(binaryDirectory);
std::string ccmd = CMAKE_COMMAND; cmake cm;
ccmd += " "; std::vector<std::string> args;
ccmd += sourceDirectory; // use this program as the cmake to be run, it should not
if (!cmSystemTools::RunCommand(ccmd.c_str(), output)) // be run that way but the cmake object requires a vailid path
std::string cmakeCommand = CMAKE_COMMAND;
if(cmakeCommand[0] = '\"')
{
cmakeCommand = cmakeCommand.substr(1, cmakeCommand.size()-2);
}
args.push_back(cmakeCommand.c_str());
args.push_back(sourceDirectory);
if (cm.Generate(args) != 0)
{ {
std::cerr << "Error: cmake execution failed\n"; std::cerr << "Error: cmake execution failed\n";
std::cerr << output.c_str() << "\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;
} }
cmListFileCache::GetInstance()->ClearCache();
// now build the test // now build the test
std::string makeCommand = MAKEPROGRAM; std::string makeCommand = MAKEPROGRAM;
makeCommand += " "; makeCommand += " ";
#ifdef _WIN32 #if defined(_WIN32) && !defined(__CYGWIN__)
makeCommand += executableName; makeCommand += executableName;
makeCommand += ".dsw /MAKE \"ALL_BUILD - Release\" /REBUILD"; makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD";
#else #else
makeCommand += " all"; makeCommand += " all";
#endif #endif
@ -75,8 +84,8 @@ int main (int argc, char *argv[])
{ {
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
} }
// try the release extension // try the Debug extension
tryPath = "Release/"; tryPath = "Debug/";
tryPath += cmSystemTools::GetFilenameName(executableName); tryPath += cmSystemTools::GetFilenameName(executableName);
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))
{ {
@ -96,7 +105,7 @@ int main (int argc, char *argv[])
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
} }
tryPath = executableDirectory; tryPath = executableDirectory;
tryPath += "/Release/"; tryPath += "/Debug/";
tryPath += executableName; tryPath += executableName;
tryPath += cmSystemTools::GetExecutableExtension(); tryPath += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))