View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012619CMakeCMakepublic2011-12-12 02:122016-06-10 14:31
Reporterchizhong jin 
Assigned ToAlex Neundorf 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformLinuxOSLinuxOS Version3.0
Product VersionCMake 2.8.5 
Target VersionFixed in Version 
Summary0012619: cmDependsC class Scan ignore same file name
DescriptioncmDependsC use cache for speed up dependences scan. But produce a bug.
When you have two or more file with same name in different directories.
cmDependsC will miss some of file.
Steps To Reproducecreate src tree like this.
xxx/
   t.h
   a.h
   src/
      a.h
      a.cpp
a.cpp include ../t.h && a.h
t.h include a.h
create a CMakeLists.txt "add_executable(a a.cpp)"
then in xxx do
$ mkdir build && cd build && cmake ../src && make
$ cat CMakeFiles/a.dir/depend.internal

we get result like:
CMakeFiles/a.dir/a.cpp.o
 /home/jcz/Desktop/src/test/cmake/samefilename/src/../t.h
 /home/jcz/Desktop/src/test/cmake/samefilename/src/a.cpp
 /home/jcz/Desktop/src/test/cmake/samefilename/src/a.h

no ../a.h
TagsNo tags attached.
Attached Filesgz file icon samefilename.tar.gz [^] (396 bytes) 2011-12-12 02:24

 Relationships
related to 0010048closedAlex Neundorf ADD_CUSTOM_COMMAND cannot handle multiple IMPLICIT_DEPENDS files 

  Notes
(0028000)
Alex Neundorf (developer)
2011-12-18 09:25

I can reproduce the problem with the attached testcase.
The on-disk cache looks ok though.

You can work around it by including "./a.h" in a.cpp.
(0028001)
Alex Neundorf (developer)
2011-12-18 09:26

There is actually a comment in the code related to this:
     // Queue the file if it has not yet been encountered and it
      // matches the regular expression for recursive scanning. Note
      // that this check does not account for the possibility of two
      // headers with the same name in different directories when one
      // is included by double-quotes and the other by angle brackets.
      // This kind of problem will be fixed when a more
      // preprocessor-like implementation of this scanner is created.

I haven't tried yet, but I guess this is what applies in this case too.
(0028059)
chizhong jin (reporter)
2011-12-23 04:13

The comment means that a header file is referenced by two different ways.
I haven't hit this problem yet.
But it is a risk if we use cmake's incremental compiling to build dailyrelease.

3ks ^_^
(0039135)
Matteo Settenvini (reporter)
2015-07-14 05:34

// Note that this check does not account for the possibility of two
// headers with the same name in different directories when one
// is included by double-quotes and the other by angle brackets.

I had quite some problems with this, as I installed headers in CMAKE_STAGING_PREFIX, and they were picked up before in-tree source files, even though I was adding the CMAKE_STAGING_PREFIX only as a system include path (resulting in "-isystem" being used by the compiler). This caused often a needless recompilation after a "make install". It was chomping away tens of minutes each time, on a big project.

The workaround I found, was putting this in my CMakeLists.txt:

set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON
    CACHE INTERNAL "Force CMake to put in-source paths before out-of-tree ones when building deps")

Even though the documentation does not say it explicitly, I've seen by reading CMake's sources that this affects the order in which paths are considered.

Actually, I think there should be a change in policy about this, and it should be ON by default. Most of the time, you want your project file always to have precedence over the others (corner cases might want to turn this off on a project-specific basis, though). Just my 2 cents.

I hope this can be useful to others.
(0041943)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2011-12-12 02:12 chizhong jin New Issue
2011-12-12 02:24 chizhong jin File Added: samefilename.tar.gz
2011-12-12 09:32 Brad King Assigned To => Alex Neundorf
2011-12-12 09:32 Brad King Status new => assigned
2011-12-18 09:25 Alex Neundorf Note Added: 0028000
2011-12-18 09:26 Alex Neundorf Note Added: 0028001
2011-12-23 04:13 chizhong jin Note Added: 0028059
2012-08-13 14:30 Alex Neundorf Target Version => CMake 2.8.10
2012-08-13 14:46 Alex Neundorf Relationship added related to 0010048
2012-10-18 14:06 Alex Neundorf Target Version CMake 2.8.10 =>
2015-07-14 05:34 Matteo Settenvini Note Added: 0039135
2016-06-10 14:28 Kitware Robot Note Added: 0041943
2016-06-10 14:28 Kitware Robot Status assigned => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team