From 290c509e119d1e3cc6efa3ee53ab80bfba9f524b Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 5 Apr 2002 09:39:13 -0500 Subject: ENH: make sure the test tests the right cmake, and not the cmake used to bootstrap this cmake --- Source/Makefile.borland | 2 +- Source/cmaketest.cxx | 45 +++++++++++++++++++++++++++------------------ Source/cmaketest.h.in | 2 +- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Source/Makefile.borland b/Source/Makefile.borland index cf497ff..852e893 100644 --- a/Source/Makefile.borland +++ b/Source/Makefile.borland @@ -36,7 +36,7 @@ cmCableClassSet.obj \ cmListFileCache.obj \ cmSourceGroup.obj -cmake: ${OBJS} +cmake.exe: ${OBJS} bcc32 -ecmake ${OBJS} diff --git a/Source/cmaketest.cxx b/Source/cmaketest.cxx index 4f35bcf..83e4e38 100644 --- a/Source/cmaketest.cxx +++ b/Source/cmaketest.cxx @@ -24,9 +24,21 @@ #include "windows.h" #endif + +// Create a class to clean up all the registered generators in case of return +struct CleanUp +{ + ~CleanUp() + { + cmMakefileGenerator::UnRegisterGenerators(); + } +}; + + // this is a test driver program for cmake. int main (int argc, char **argv) { + CleanUp cleanup; if (argc < 4) { std::cerr << "Usage: " << argv[0] << " test-src-dir test-bin-dir test-executable\n"; @@ -69,20 +81,22 @@ int main (int argc, char **argv) cmSystemTools::ChangeDirectory(binaryDirectory); std::vector args; + std::string intdir = "."; +#ifdef CMAKE_INTDIR + intdir = CMAKE_INTDIR; +#endif // make sure the same generator is used // use this program as the cmake to be run, it should not // be run that way but the cmake object requires a vailid path - std::string cmakeCommand = CMAKE_COMMAND; - if(cmakeCommand[0] == '\\' && cmakeCommand[1] == '\"') - { - cmakeCommand = cmakeCommand.substr(2, cmakeCommand.size()-4); - } - if(cmakeCommand[0] == '\"') - { - cmakeCommand = cmakeCommand.substr(1, cmakeCommand.size()-2); - } + std::string cmakeCommand = CMAKE_BINARY_DIR; + cmakeCommand += "/Source"; + cmakeCommand += "/"; + cmakeCommand += intdir; + cmakeCommand += "/cmake"; + cmakeCommand += cmSystemTools::GetExecutableExtension(); + std::cout << "*** " << cmakeCommand << "\n"; args.push_back(cmakeCommand.c_str()); args.push_back(sourceDirectory); std::string generator = "-G"; @@ -143,10 +157,6 @@ int main (int argc, char **argv) std::string lowerCaseCommand = makeCommand; cmSystemTools::LowerCase(lowerCaseCommand); std::string dartMakeCommand = DART_MAKECOMMAND; - std::string buildtype = "Debug"; -#ifdef CMAKE_INTDIR - buildtype = CMAKE_INTDIR; -#endif // if msdev is the make program then do the following // MSDEV 6.0 if(lowerCaseCommand.find("msdev") != std::string::npos) @@ -163,7 +173,7 @@ int main (int argc, char **argv) makeCommand += " "; makeCommand += projectName; makeCommand += ".dsw /MAKE \"ALL_BUILD - "; - makeCommand += buildtype + "\" /REBUILD"; + makeCommand += intdir + "\" /REBUILD"; } // MSDEV 7.0 .NET else if (lowerCaseCommand.find("devenv") != std::string::npos) @@ -177,7 +187,7 @@ int main (int argc, char **argv) makeCommand += " "; makeCommand += projectName; makeCommand += ".sln /rebuild "; - makeCommand += buildtype + " /project ALL_BUILD"; + makeCommand += intdir + " /project ALL_BUILD"; } // command line make program else @@ -224,7 +234,7 @@ int main (int argc, char **argv) fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); } // try the Debug extension - tryPath = buildtype + "/"; + tryPath = intdir + "/"; tryPath += cmSystemTools::GetFilenameName(executableName); if(cmSystemTools::FileExists(tryPath.c_str())) { @@ -245,7 +255,7 @@ int main (int argc, char **argv) } tryPath = executableDirectory; tryPath += "/"; - tryPath += buildtype + "/"; + tryPath += intdir + "/"; tryPath += executableName; tryPath += cmSystemTools::GetExecutableExtension(); if(cmSystemTools::FileExists(tryPath.c_str())) @@ -280,7 +290,6 @@ int main (int argc, char **argv) std::cout << output << "\n"; // return to the original directory cmSystemTools::ChangeDirectory(cwd.c_str()); - cmMakefileGenerator::UnRegisterGenerators(); if(ret) { cmSystemTools::Error("test executable ", fullPath.c_str(), diff --git a/Source/cmaketest.h.in b/Source/cmaketest.h.in index 61ae7aa..7da7315 100644 --- a/Source/cmaketest.h.in +++ b/Source/cmaketest.h.in @@ -1,4 +1,4 @@ -#define CMAKE_COMMAND "${CMAKE_COMMAND}" +#define CMAKE_BINARY_DIR "${CMake_BINARY_DIR}" #define MAKEPROGRAM "${MAKEPROGRAM}" #define CMAKE_GENERATOR "${CMAKE_GENERATOR}" #define DART_MAKECOMMAND "${MAKECOMMAND}" -- cgit v0.12