Hi,
here is description of the problem:
http://www.cmake.org/pipermail/cmake/2013-October/056008.html

in short, cmake not handle dependencies of c/c++ source file from c/c++
header file, if source file has utf-8 BOM.
So, if for example in your team used Visual Studio with preference to
save files in utf-8 (Qt 5 now works only with UTF-8),
and linux+cmake+gcc, then someday you see
that you change header files, but corresponded c++ source file was not
recompiled.

Here (in attachment) is possible solution of this problem (it passes all tests,
except two, but they fails and without this patch).

-- 
/Evgeniy
>From 66a1f409f287af53725c513627da1940afb06465 Mon Sep 17 00:00:00 2001
From: "Evgeniy A. Dushistov" <dushis...@mail.ru>
Date: Mon, 14 Oct 2013 11:56:50 +0400
Subject: [PATCH] handle c dependicies for files with utf-8 BOM

---
 Source/cmDependsC.cxx | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index a252a1a..1d05797 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -249,6 +249,14 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
           std::ifstream fin(fullName.c_str());
           if(fin)
             {
+	      static const unsigned char UTF8_BOM[3] = {0xEF, 0xBB, 0xBF};
+	      unsigned char bom[3];
+	      fin.read(reinterpret_cast<char *>(bom), sizeof(bom));
+	      if ((fin && !(bom[0] == UTF8_BOM[0] && bom[1] == UTF8_BOM[1] && bom[2] == UTF8_BOM[2])) || !fin) 
+		{
+		  fin.clear();
+		  fin.seekg(0, std::ios::beg);
+		}
             // Add this file as a dependency.
             dependencies.insert(fullName);
 
-- 
1.8.1.5

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to