#
function(ExternalSource_Download PREFIX)
include(CMakeParseArguments)
+ nncc_include(StampTools)
cmake_parse_arguments(ARG "" "DIRNAME;URL;CHECKSUM" "" ${ARGN})
endif(NOT EXISTS "${CACHE_DIR}")
# Compare URL in STAMP file and the given URL
- # - Remove STAMP if they are unmatched
- if(EXISTS "${STAMP_PATH}")
- file(READ ${STAMP_PATH} PREV_URL)
+ Stamp_Check(URL_CHECK "${STAMP_PATH}" "${URL}")
- if(NOT URL STREQUAL PREV_URL)
- file(REMOVE "${STAMP_PATH}")
- endif(NOT URL STREQUAL PREV_URL)
- endif(EXISTS "${STAMP_PATH}")
-
- if(NOT EXISTS "${STAMP_PATH}")
+ if(NOT URL_CHECK)
+ file(REMOVE "${STAMP_PATH}")
file(REMOVE_RECURSE "${OUT_DIR}")
file(REMOVE_RECURSE "${TMP_DIR}")
--- /dev/null
+# Stamp_Check(VARNAME PATH CONTENT)
+# Stamp_Check sets VARNAME as TRUE if a file exists at "PATH", and its content is same as "CONTENT"
+# Stamp_Check sets VARNAME as FALSE otherwise
+function(Stamp_Check VARNAME PATH EXPECTED_CONTENT)
+ if(NOT EXISTS "${PATH}")
+ set(${VARNAME} FALSE PARENT_SCOPE)
+ return()
+ endif(NOT EXISTS "${PATH}")
+
+ file(READ ${PATH} OBTAINED_CONTENT)
+
+ if(NOT EXPECTED_CONTENT STREQUAL OBTAINED_CONTENT)
+ set(${VARNAME} FALSE PARENT_SCOPE)
+ return()
+ endif(NOT EXPECTED_CONTENT STREQUAL OBTAINED_CONTENT)
+
+ set(${VARNAME} TRUE PARENT_SCOPE)
+endfunction(Stamp_Check)