c++ - How to change file permission when copying by add_custom_command in cmake -


i able copy files cmake using like

file(glob images ${project_source_dir}/image/*) file(copy ${images} destination ${cmake_current_binary_dir}/image      file_permissions owner_read owner_write group_write group_read world_read) 

but downside command invoked when cmake reconfigured. figured out way copy them whenever build triggered below

add_custom_command(target ${project_name} post_build                   command ${cmake_command} -e copy_directory                   "${project_source_dir}/image"                   "${cmake_current_binary_dir}/image") 

this suits needs not able figure out way alter file permission first method. need alternate file permission make sure right otherwise images might wrongly classified executable when running below command

find . -executable -type f 

is possible alter file permission when copying add_custom_command?

cmake developers responds answer works. key creating temporary cmake script file(copy) in , invoke it.

file(glob images ${project_source_dir}/image/*)  file(write "${cmake_current_binary_dir}/foo.cmake" "file(copy ${images}  destination ${cmake_current_binary_dir}/image  file_permissions owner_read owner_write group_write group_read world_read)")  add_custom_command(target ${project_name} post_build command  ${cmake_command} -p ${cmake_current_binary_dir}/foo.cmake) 

Comments