概述
- 本文将介绍使用 execute_process 实现 文件夹 创建、文件夹拷贝 和文件拷贝
创建文件夹
set(public_include ${CMAKE_CURRENT_SOURCE_DIR}/public)
# 创建 public_include 指向的文件夹
execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${public_include})
拷贝文件夹
set(save_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/output)
# 拷贝 src文件夹下的内容 到 save_src_dir 中
execute_process( COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${save_src_dir})
拷贝文件
set(public_include ${CMAKE_CURRENT_SOURCE_DIR}/public)
# 拷贝 main.cpp 到 public_include 中
execute_process( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ${public_include})