[cmake-developers] Using reflinks during install phase

Brad King brad.king at kitware.com
Mon Jun 2 10:06:04 EDT 2014


On 06/02/2014 09:40 AM, Alessandro Di Federico wrote:
> I suggest to check version from `cp --version`

Okay.  I see the version output contains "GNU coreutils" too so that
can help verify that the version number is meaningful.

> I'm very new to CMake code base, what is the most appropriate location
> for a check like this?

Currently the file installation is in cmFileCopier::InstallFile here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmFileCommand.cxx;hb=v3.0.0-rc6#l1548

The call to cmSystemTools::CopyAFile should be refactored to invoke
"cp" or fall back to CopyAFile depending on the detection result.
We don't use threading so it should be safe to store the detection
result in a function-scoped static variable, e.g.

 static bool const useRefLink = cmFileCopier::DetectUseReflink();
 if(useRefLink)
   {
   // ... cp ...
   }
 else
   {
   // ... cmSystemTools::CopyAFile ...
   }

To run the child you can use cmSystemTools::RunSingleCommand:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmSystemTools.h;hb=v3.0.0-rc6#l193

Use one of the overloads that takes a vector of arguments rather
than a command-line string.

Thanks,
-Brad




More information about the cmake-developers mailing list