diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2002-01-23 15:56:21 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2002-01-23 15:56:21 (GMT) |
commit | 8a4a39d568cff55831c4fad19d046c396896a2e5 (patch) | |
tree | 3d757e7f8bbb92b25b64ef206eac6f8b07249684 /Source/cmaketest.cxx | |
parent | deba0b2317b3863168d1b7fed9201058aa0dccd7 (diff) | |
download | CMake-8a4a39d568cff55831c4fad19d046c396896a2e5.zip CMake-8a4a39d568cff55831c4fad19d046c396896a2e5.tar.gz CMake-8a4a39d568cff55831c4fad19d046c396896a2e5.tar.bz2 |
ENH: run CMake a second time. The first time it is run, some cache values are computed. The second time it is run, some commands check if the value is already in the cache and return that value instead of re-computing it. Therefore this ENH: a) make sure that this specific code is tested, b) increase coverage.
Diffstat (limited to 'Source/cmaketest.cxx')
-rw-r--r-- | Source/cmaketest.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/cmaketest.cxx b/Source/cmaketest.cxx index bf3e1dd..707f183 100644 --- a/Source/cmaketest.cxx +++ b/Source/cmaketest.cxx @@ -36,20 +36,24 @@ int main (int argc, char *argv[]) { cmSystemTools::MakeDirectory(argv[2]); } + const char* sourceDirectory = argv[1]; const char* binaryDirectory = argv[2]; const char* executableName = argv[3]; const char* executableDirectory = ""; + if(argc > 4) { executableDirectory = argv[4]; } + const char* projectName = executableName; if(argc > 5) { projectName = argv[5]; } + /** * Run an executable command and put the stdout in output. */ @@ -60,8 +64,9 @@ int main (int argc, char *argv[]) std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::cout << "Changing into directory: " << binaryDirectory << "\n"; cmSystemTools::ChangeDirectory(binaryDirectory); - cmake cm; + std::vector<std::string> args; + // 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 @@ -74,12 +79,15 @@ int main (int argc, char *argv[]) { cmakeCommand = cmakeCommand.substr(1, cmakeCommand.size()-2); } + args.push_back(cmakeCommand.c_str()); args.push_back(sourceDirectory); std::string generator = "-G"; generator += CMAKE_GENERATOR; args.push_back(generator); std::cout << "Generating build files...\n"; + + cmake cm; if (cm.Generate(args) != 0) { std::cerr << "Error: cmake execution failed\n"; @@ -88,7 +96,20 @@ int main (int argc, char *argv[]) return 1; } std::cout << "Done Generating build files.\n"; + + cmake cm2; + std::cout << "Generating build files (again)...\n"; + if (cm2.Generate(args) != 0) + { + std::cerr << "Error: cmake execution failed\n"; + // return to the original directory + cmSystemTools::ChangeDirectory(cwd.c_str()); + return 1; + } + std::cout << "Done Generating build files (again).\n"; + cmListFileCache::GetInstance()->ClearCache(); + // now build the test std::string makeCommand = MAKEPROGRAM; if(makeCommand.size() == 0) @@ -101,6 +122,7 @@ int main (int argc, char *argv[]) #endif std::string lowerCaseCommand = makeCommand; cmSystemTools::LowerCase(lowerCaseCommand); + // if msdev is the make program then do the following if(lowerCaseCommand.find("msdev") != std::string::npos) { @@ -129,7 +151,7 @@ int main (int argc, char *argv[]) // clean first std::string cleanCommand = makeCommand; cleanCommand += " clean"; - std::cout << "Running make command: " << cleanCommand.c_str() << " ...\n"; + std::cout << "Running make clean command: " << cleanCommand.c_str() << " ...\n"; if (!cmSystemTools::RunCommand(cleanCommand.c_str(), output)) { std::cerr << "Error: " << cleanCommand.c_str() << " execution failed\n"; |