Closed kobi-ca closed 4 years ago
This one is actually easier - you can do something like the following. add_custom_target is considered "always out of date" so it will always run.
set(DESCRIBEFILE ${CMAKE_CURRENT_BINARY_DIRECTORY}/git-describe-results.txt)
add_custom_target(git-describe-target
ALL
"${GIT_EXECUTABLE}" describe --dirty > "${DESCRIBEFILE}"
BYPRODUCTS "${DESCRIBEFILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running git describe"
VERBATIM)
Then you can freely use ${DESCRIBEFILE}
though you'll want to add_dependencies()
from wherever you use it, to the git-describe-target. Might need to mark DESCRIBEFILE as generated if you use it as a source file, not sure. (You can modify the command line here however you please - I assumed --dirty because the script should get triggered to re-configure if you only care about commits.)
Let me know if this helps!
thanks!
Hi,
Is there a way to run git_describe in every build and not just in generation time? thanks, Kobi