[cmake-developers] [CMake 0015493]: incorrect file parsing, if it has a BOM-header

Mantis Bug Tracker mantis at public.kitware.com
Fri Apr 3 10:58:48 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15493 
====================================================================== 
Reported By:                Aleksey Konovalov
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15493
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-04-03 10:58 EDT
Last Modified:              2015-04-03 10:58 EDT
====================================================================== 
Summary:                    incorrect file parsing, if it has a BOM-header
Description: 
The #include directive in the first line of the c/c++ source file is ignored if
the file contains a BOM-header. In this case, the file depend.make is not
included this header file and its dependencies.

My patch fixes this problem:

>From 281e67e98961c1b2dcf0979dc3a38d5a1fa0b42a Mon Sep 17 00:00:00 2001
From: Aleksey Konovalov <konovalov.aleks at gmail.com>
Date: Fri, 3 Apr 2015 17:38:11 +0300
Subject: [PATCH] Skipping BOM-header while parsing a C-source

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

diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 63d8fa6..60937b6 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -242,6 +242,9 @@ bool cmDependsC::WriteDependencies(const
std::set<std::string>& sources,
           cmsys::ifstream fin(fullName.c_str());
           if(fin)
             {
+            // Skip BOM-header if it exists
+            cmsys::FStream::ReadBOM(fin);
+
             // Add this file as a dependency.
             dependencies.insert(fullName);
 
-- 
1.8.1.4



Steps to Reproduce: 
Attached file cmake_test.zip contains test-project. File test.cpp contains
BOM-header in first line. CMake ignores this #include directive and does not add
test.h to depend.make. Because of this, compilation does not occur when you
modify test.h


Additional Information: 
current depend.make content:
---------------------------------------------------------------
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

CMakeFiles/test.dir/test.cpp.o: ../test.cpp

---------------------------------------------------------------

expected depend.make content:
---------------------------------------------------------------
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.2

CMakeFiles/test.dir/test.cpp.o: ../test.cpp
CMakeFiles/test.dir/test.cpp.o: ../test.h


---------------------------------------------------------------
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-04-03 10:58 Aleksey KonovalovNew Issue                                    
2015-04-03 10:58 Aleksey KonovalovFile Added: cmake_test.zip                    
======================================================================



More information about the cmake-developers mailing list