Reputation: 6561
I have an external project:
ExternalProject_Add(
lighttpd
URL "${PROJECT_SOURCE_DIR}/ext/lighttpd/lighttpd.tar.gz"
SOURCE_DIR "${EXTERNAL_INSTALL_PATH}/lighttpd"
)
ExternalProject_Add_Step(
lighttpd copy2build
COMMAND cp -a ${EXTERNAL_INSTALL_PATH}/lighttpd/bin/. ${EXECUTABLE_OUTPUT_PATH}
COMMAND cp -a ${EXTERNAL_INSTALL_PATH}/lighttpd/lib/. ${LIBRARY_OUTPUT_PATH}
DEPENDEES install
)
The problem is that CMake is not rebuilding lighttpd
if lighttpd.tar.gz
changes. How can I tell CMake to rebuild this external project if lighttpd.tar.gz
changes?
Upvotes: 4
Views: 800
Reputation: 17197
This is an interesting problem that I don't think ExternalProject_Add
solves by it's own.
Note that ExternalProject_Add_Step
has an option ALWAYS
that you can set to 1
or 0
. We'll use that in the following workaround/solution.
You can compute the hash of the file using the following:
file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> filename file_hash)
You can then save this variable
as an internal cache variable
set(TAR_BALL_HASH ${file_hash} CACHE INTERNAL "")
You can then compare the two variables and if they are the same, set the ALWAYS
option of your ExternalProject_Add_Step
to 1
, otherwise, set it to 0
.
Upvotes: 1