View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015493CMakeCMakepublic2015-04-03 10:582015-11-02 09:13
ReporterAleksey Konovalov 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionCMake 3.3Fixed in VersionCMake 3.3 
Summary0015493: incorrect file parsing, if it has a BOM-header
DescriptionThe #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@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 ReproduceAttached 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 Informationcurrent 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


---------------------------------------------------------------
TagsNo tags attached.
Attached Fileszip file icon cmake_test.zip [^] (376 bytes) 2015-04-03 10:58

 Relationships

  Notes
(0038396)
Brad King (manager)
2015-04-03 13:24

Thanks. I made a change similar to yours and added a test case:

 Makefile: Tolerate a BOM while scanning source dependencies
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=af924827 [^]
(0039757)
Robert Maynard (manager)
2015-11-02 09:13

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-04-03 10:58 Aleksey Konovalov New Issue
2015-04-03 10:58 Aleksey Konovalov File Added: cmake_test.zip
2015-04-03 13:24 Brad King Note Added: 0038396
2015-04-03 13:25 Brad King Assigned To => Brad King
2015-04-03 13:25 Brad King Status new => resolved
2015-04-03 13:25 Brad King Resolution open => fixed
2015-04-03 13:25 Brad King Fixed in Version => CMake 3.3
2015-04-03 13:25 Brad King Target Version => CMake 3.3
2015-11-02 09:13 Robert Maynard Note Added: 0039757
2015-11-02 09:13 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team