From cd6dd5533020357b4aa7455a17f23ddcf80b4e73 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Feb 2005 08:50:53 -0500 Subject: ENH: Added generation of test target to run ctest. --- Source/cmLocalUnixMakefileGenerator2.cxx | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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 no_depends; + std::vector 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 no_depends; -- cgit v0.12