0

I'm new to Cmake and I have a main output named TARGET. I'm trying to add custom target named _COPY_ASSETS_TARGET as a dependency to main TARGET. I want TARGET to rebuild _COPY_ASSETS_TARGET automatically if there's any change in _COPY_ASSETS_TARGET. _COPY_ASSETS_TARGET should depend on change in folders.

Here's the code I tried to implement:

 if (NOT TARGET ${_COPY_ASSETS_TARGET})
            add_custom_target(${_COPY_ASSETS_TARGET})
            add_dependencies(${_ARGS_PROJECT_TARGET} ${_COPY_ASSETS_TARGET})
            set_property(TARGET ${_COPY_ASSETS_TARGET} PROPERTY FOLDER "Targets")
        endif()

        add_custom_command(TARGET ${_COPY_ASSETS_TARGET}
            ${_COMMANDS}
            VERBATIM
        )

I'm trying visual studio to debug and if I rebuild _COPY_ASSETS_TARGET then only I can see the updated output. I would like to know how I can link my folders to _COPY_ASSETS_TARGET so that TARGET automatically builds new code

1 Answers1

1
add_custom_command(OUTPUT ${OUTPUT_DIRECTORY} ${_COMMANDS}
            DEPENDS ${DEPENDENT_DIRECTORY}
            VERBATIM
        )

        add_custom_target(${_COPY_ASSETS_TARGET} ALL 
            DEPENDS ${OUTPUT_DIRECTORY}
        )

        add_dependencies(${_ARGS_PROJECT_TARGET} ${_COPY_ASSETS_TARGET})
        set_property(TARGET ${_COPY_ASSETS_TARGET} PROPERTY FOLDER "Targets")

I found this to be working for my project