Answers:
您何时要创建目录?
要在CMake生成构建系统时创建目录,
file(MAKE_DIRECTORY ${directory})
在add_custom_command()
命令(将自定义构建规则添加到生成的构建系统中)和add_custom_target()
命令(添加无输出目标,以便始终构建目标)中,您指定要在构建时执行的命令。通过执行命令创建目录${CMAKE_COMMAND} -E make_directory
。例如:
add_custom_target(build-time-make-directory ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})
要在安装时创建目录,
install(DIRECTORY DESTINATION ${directory})
要在安装时创建目录,
install(DIRECTORY DESTINATION ${directory})
这些都将在配置时运行:
file(MAKE_DIRECTORY ${directory})
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})
要在构建期间创建,请使用自定义目标:
add_custom_target(mytargetname ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})