How to change file resolution when copying using add_custom_command in cmake

I can copy files using cmake using something 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 the disadvantage is that this command will only be called when cmake is reconfigured. I figured out a way to copy them whenever the assembly is called, as shown 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 my needs, I can’t find a way to change the file resolution as the first method. I need to change the resolution of the file to make sure it is right, otherwise some images may not be correctly classified as executable when running the command below

find . -executable -type f

Is it possible to change the file resolution when copying from add_custom_command?

0
source share
1

CMake , . cmake script (COPY) .

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)
+1

Source: https://habr.com/ru/post/1653382/


All Articles