[CMake] CTest with multiple directories: problem with absolute paths

Bill V vodall at gmail.com
Fri May 29 20:44:27 EDT 2009


> Tyler said:
> Btw, there is a discrepancy between how subdirs works in CTest vs how it
> works in CMake. Compare CTest/cmCTestTestHandler::cmCTestSubdirCommand
> with cmSubdirCommand::cmSubdirCommand.
>

I added a small test for relative vs absolute paths to
ctest/cmCTestTestHandler.cxx. The modified ctest is happily following
the SUBDIR absolute path entries from several subprojects to the point
of finding and running the actual unittests.

> The one for CMake has some logic that checks if
> Makefile->GetCurrentDirectory/directory_from_subdir_command points
> somewhere useful. If it does, cmSubdirCommand adds the directory with
> the prepended current directory. (If not, it returns
> directory_from_subdir_command undecorated.)
>
> cmCTestSubdirCommand doesn't have this logic; it always prepends
> GetCurrentWorkingDirectory() with no tests to make sure the resulting
> decorated directory exists on the filesystem.


The essence of my change is the test for FileIsDirectory.

---  ctest/cmCTestTestHandler.cxx ---

bool cmCTestSubdirCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
{
 ...
  std::vector<std::string>::const_iterator it;
  std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
  for ( it = args.begin(); it != args.end(); ++ it )
    {
    cmSystemTools::ChangeDirectory(cwd.c_str());
    std::string fname = cwd;
    fname += "/";
    fname += *it;
	
*    if ( !cmSystemTools::FileIsDirectory(fname.c_str()) )
*    {
*        fname = *it;
*    }

-----

I haven't tested this yet with a cmake build tree that has relative
entries in the CTestTest.cmake files so there may be issues but for
now this looks good enough to keep us going until a real solution is
in place.

Thanks,
Bill


More information about the CMake mailing list