Category Archives: CMake

Copy a file with CMake

Copy Podfile at the build stage:

message("Copy ${CMAKE_CURRENT_SOURCE_DIR}/Podfile -> ${CMAKE_BINARY_DIR}")
add_custom_target(copy_podfile
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${CMAKE_CURRENT_SOURCE_DIR}/Podfile"
        "${CMAKE_BINARY_DIR}"
    COMMENT "Copying Podfile"
)
add_dependencies(${PROJECT_NAME} copy_podfile)

Copy Podfile at the configuration stage:

execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
    "${CMAKE_CURRENT_SOURCE_DIR}/Podfile"
    "${CMAKE_BINARY_DIR}"
)