Cmake File COPY 跨驱动器
Cmake File COPY across drives
以下无效:
cmake file ( copy "C:/pathtofile/file.file" DESTINATION "D:/pathtofile2/file2.file" )
有没有办法使用 cmake 实现同样的事情?
cmakes fantastic 配置文件系统将起作用。这些文件可以有不同的名称,但基本上如果它找到任何可以通过 cmake 扩展的变量,如 ${cmake_root_dir} 或 $ENV{localappdata},它将编辑文件,用它们的值替换变量并保存以新名称将其移动到新位置。所以如果没有变量,它只是复制。
Configure_file( C:/pathtofile/file.file" "D:/pathtofile2/file2.file")
如果你出于某种原因在那里有 cmake 样式变量并且你不想扩展它们,请使用 @Only 因为它只会扩展被“@”包围的变量:
Configure_file( C:/pathtofile/file.file" "D:/pathtofile2/file2.file" @ONLY)
文档指出 DESTINATION 必须是一个目录。因此,以这种方式重命名文件不起作用。
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "C:/pathtofile/file.file" "D:/pathtofile2/file2.file")
应该可以。
以下无效:
cmake file ( copy "C:/pathtofile/file.file" DESTINATION "D:/pathtofile2/file2.file" )
有没有办法使用 cmake 实现同样的事情?
cmakes fantastic 配置文件系统将起作用。这些文件可以有不同的名称,但基本上如果它找到任何可以通过 cmake 扩展的变量,如 ${cmake_root_dir} 或 $ENV{localappdata},它将编辑文件,用它们的值替换变量并保存以新名称将其移动到新位置。所以如果没有变量,它只是复制。
Configure_file( C:/pathtofile/file.file" "D:/pathtofile2/file2.file")
如果你出于某种原因在那里有 cmake 样式变量并且你不想扩展它们,请使用 @Only 因为它只会扩展被“@”包围的变量:
Configure_file( C:/pathtofile/file.file" "D:/pathtofile2/file2.file" @ONLY)
文档指出 DESTINATION 必须是一个目录。因此,以这种方式重命名文件不起作用。
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "C:/pathtofile/file.file" "D:/pathtofile2/file2.file")
应该可以。