MantisBT - CMake
View Issue Details
0009354CMakeCMakepublic2009-08-04 01:572016-06-10 14:30
Christian Luidolt 
Brad King 
normalminoralways
closedmoved 
CMake-2-6 
 
0009354: wrong C dependency if header file has same name as standard header file
A project specific include path is set.

In this include directory one header file (headers.h) includes another header file (assert.h) which has the same name as a system header file.

To reproduce the error, the system header file must also included (directly or indirectly) by the C++ file.

The generated CMakeFiles/IncludeTest.dir/depend.make file does not show the dependency to the "private" assert.h - so the C++ file is not rebuild if assert.h is modified.
No tags attached.
related to 0015003closed Kitware Robot depend.make ignores files with the same name 
tgz includetest.tgz (551) 2009-08-04 01:57
https://public.kitware.com/Bug/file/2393/includetest.tgz
Issue History
2009-08-04 01:57Christian LuidoltNew Issue
2009-08-04 01:57Christian LuidoltFile Added: includetest.tgz
2009-08-04 08:49Bill HoffmanStatusnew => assigned
2009-08-04 08:49Bill HoffmanAssigned To => Brad King
2009-08-04 10:27Brad KingNote Added: 0017053
2012-08-13 10:37Brad KingStatusassigned => backlog
2012-08-13 10:37Brad KingNote Added: 0030535
2014-07-03 09:22Brad KingRelationship addedrelated to 0015003
2016-06-10 14:27Kitware RobotNote Added: 0041584
2016-06-10 14:27Kitware RobotStatusbacklog => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0017053)
Brad King   
2009-08-04 10:27   
This is a known limitation, and is mentioned in a comment in the implementation. See the source file "Source/cmDependsC.cxx", in the method "cmDependsC::Scan":

http://www.cmake.org/cgi-bin/viewcvs.cgi/Source/cmDependsC.cxx?revision=1.35&root=CMake&view=markup [^]

The comment reads:

  "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."

The comment isn't quite right this case, but is very similar (using quotes in main.cxx won't help in your case). The same problem would occur if you created an "assert.h" next to main.cxx and included it via double-quotes.

Basically the whole scanner implementation assumes unique header names within a translation unit. A better approach would assume uniqueness only inside a single source or header, but that will take significant changes. I don't know when I'll have time to do this, but if anyone reading this issue wants to volunteer I'm happy to advise.

A work-around is to change

  #include "assert.h"

in "headers.h" to read

  #include "./assert.h"

or

  #include <inc/assert.h>

or

  #include "assert.h"
  #if 0
  # include "./assert.h" // work-around CMake scanning problem
  #endif

or to rename the header.
(0030535)
Brad King   
2012-08-13 10:37   
Sending issues I'm not actively working on to the backlog to await someone with time for them.

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it:

 http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer or contributor who has the bandwidth to take it on.
(0041584)
Kitware Robot   
2016-06-10 14:27   
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.