- I have target for shared and want it to run command after build ONLY if the Target output file changed, or same for me if build is updating. In my example command runes every time when I build project, but I need it to run Only if after build Target output file changed
cmake_minimum_required(VERSION 3.21)
project(myexp)
add_library(Example SHARED source.cpp)
set_target_properties(Example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin$<0:>"
)
add_custom_command(TARGET Example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Example> ${CMAKE_CURRENT_SOURCE_DIR}/new
DEPENDS Example
)
DEPENDS
doesnt work here
from documentation - add_custom_command
The second signature adds a custom command to a target such as a library or executable.
This is useful for performing an operation before or after building the target.
The command becomes part of the target and will only execute when the target itself is
built.
If the target is already built, the command will not execute.
maybe my understanding of this is wrong
- is there a way to Multi-OUTPUT
THANK YOU