[CMake] file(SHA1) vs string(SHA1) consistency
Ruslan Baratov
ruslan_baratov at yahoo.com
Thu Feb 25 09:58:38 EST 2016
Hi,
Following code produce same SHA1 on Linux:
cmake_minimum_required(VERSION 3.0)
set(test_string "a\nb")
set(test_file "test.file")
string(SHA1 sha1_string "${test_string}")
file(WRITE "${test_file}" "${test_string}")
file(SHA1 "${test_file}" sha1_file)
message("sha1:")
message(" ${sha1_file}")
message(" ${sha1_string}")
result:
sha1:
fcd127ffa1016069006ad91f3f361248f9bdf272
fcd127ffa1016069006ad91f3f361248f9bdf272
but not same SHA1 on Windows:
sha1:
ec6cb5b8c69f8b476a380c9b6e38e18c2733ae7b
fcd127ffa1016069006ad91f3f361248f9bdf272
I think this is because of DOS end of lines. Two thoughts:
* file(SHA1) and string(SHA1) should be the same on same input string
* since CMake is a cross-platform tool I think it make sense that
command `file(WRITE "..." "a\nb")` produce identical files on all platforms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160225/2b943d0e/attachment.html>
More information about the CMake
mailing list