diff --git a/Builds/CMake/deps/Rocksdb.cmake b/Builds/CMake/deps/Rocksdb.cmake index eed6cefe16..5437bea911 100644 --- a/Builds/CMake/deps/Rocksdb.cmake +++ b/Builds/CMake/deps/Rocksdb.cmake @@ -63,7 +63,7 @@ if (local_rocksdb) GIT_TAG v6.7.3 PATCH_COMMAND # only used by windows build - ${CMAKE_COMMAND} -E copy + ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake/rocks_thirdparty.inc /thirdparty.inc COMMAND diff --git a/Builds/CMake/soci_patch.cmake b/Builds/CMake/soci_patch.cmake index 7d0f9eb848..57c46e5821 100644 --- a/Builds/CMake/soci_patch.cmake +++ b/Builds/CMake/soci_patch.cmake @@ -1,13 +1,30 @@ # This patches unsigned-types.h in the soci official sources # so as to remove type range check exceptions that cause # us trouble when using boost::optional to select int values + +# Some versions of CMake erroneously patch external projects on every build. +# If the patch makes no changes, skip it. This workaround can be +# removed once we stop supporting vulnerable versions of CMake. +# https://gitlab.kitware.com/cmake/cmake/-/issues/21086 file (STRINGS include/soci/unsigned-types.h sourcecode) +# Delete the .patched file if it exists, so it doesn't end up duplicated. +# Trying to remove a file that does not exist is not a problem. +file (REMOVE include/soci/unsigned-types.h.patched) foreach (line_ ${sourcecode}) if (line_ MATCHES "^[ \\t]+throw[ ]+soci_error[ ]*\\([ ]*\"Value outside of allowed.+$") set (line_ "//${CMAKE_MATCH_0}") endif () file (APPEND include/soci/unsigned-types.h.patched "${line_}\n") endforeach () +execute_process( COMMAND ${CMAKE_COMMAND} -E compare_files + include/soci/unsigned-types.h include/soci/unsigned-types.h.patched + RESULT_VARIABLE compare_result +) +if( compare_result EQUAL 0) + message(DEBUG "The soci source and patch files are identical. Make no changes.") + file (REMOVE include/soci/unsigned-types.h.patched) + return() +endif() file (RENAME include/soci/unsigned-types.h include/soci/unsigned-types.h.orig) file (RENAME include/soci/unsigned-types.h.patched include/soci/unsigned-types.h) # also fix Boost.cmake so that it just returns when we override the Boost_FOUND var