diff options
author | Brad King <brad.king@kitware.com> | 2005-02-17 13:50:53 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-02-17 13:50:53 (GMT) |
commit | cd6dd5533020357b4aa7455a17f23ddcf80b4e73 (patch) | |
tree | e53ef7ea71ba1d12f372e8240bf1627b9555024d /Source/cmLocalUnixMakefileGenerator2.cxx | |
parent | 2651d170d554040502b330c41acccbfddbd8122e (diff) | |
download | CMake-cd6dd5533020357b4aa7455a17f23ddcf80b4e73.zip CMake-cd6dd5533020357b4aa7455a17f23ddcf80b4e73.tar.gz CMake-cd6dd5533020357b4aa7455a17f23ddcf80b4e73.tar.bz2 |
ENH: Added generation of test target to run ctest.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator2.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index a9e2d9f..ee759af 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -1033,6 +1033,40 @@ cmLocalUnixMakefileGenerator2 no_commands); } + // Write special "test" target to run ctest. + if(m_Makefile->IsOn("CMAKE_TESTING_ENABLED")) + { + std::string ctest; + if(m_Makefile->GetDefinition("CMake_BINARY_DIR")) + { + // We are building CMake itself. Use the ctest that comes with + // this version of CMake instead of the one used to build it. + ctest = m_ExecutableOutputPath; + ctest += "ctest"; + ctest += cmSystemTools::GetExecutableExtension(); + ctest = this->ConvertToRelativeOutputPath(ctest.c_str()); + } + else + { + // We are building another project. Use the ctest that comes with + // the CMake building it. + ctest = m_Makefile->GetRequiredDefinition("CMAKE_COMMAND"); + ctest = cmSystemTools::GetFilenamePath(ctest.c_str()); + ctest += "/"; + ctest += "ctest"; + ctest += cmSystemTools::GetExecutableExtension(); + ctest = this->ConvertToOutputForExisting(ctest.c_str()); + } + std::vector<std::string> no_depends; + std::vector<std::string> commands; + std::string cmd = ctest; + cmd += " $(ARGS)"; + commands.push_back(cmd); + this->WriteMakeRule(makefileStream, + "Special rule to drive testing with ctest.", + "Running tests...", "test", no_depends, commands); + } + // Write special "install" target to run cmake_install.cmake script. { std::vector<std::string> no_depends; |