Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-17971

Explicitly added headers of CMake target do not have correct include search path in clang code model

    XMLWordPrintable

    Details

      Description

      If you add a header to a CMake target explicitly via target_sources, the clang code model does not search that target's include paths when resolving any other files the header includes.

      If the header isn't explicitly added (so that it appears under <Headers> after being found implicitly) it does get the correct include search paths applied.

      The explicit case worked in 4.2

      See attached project:

      If the project is opened as is,
      #include "testlib/bar.h"
      in foo.h is flagged up by the clang code model (although it builds fine)

      if you remove "include/testlib/foo.h" from the sources listed in testlib/CMakeLists.txt, foo.h moves from the testlib target to the <Headers> section.
      #include "testlib/bar.h" is no longer highlighted as an error by the Clang code model.

      Note that for the error case, if you open the C++ code model inspector, there does exist a context with the correct include paths, but it's not one of those listed in the parse contexts drop-down for foo.h, so it can't be selected.

        Attachments

        1. testcase.tar
          8 kB
        2. testproj.zip
          9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            hunger Tobias Hunger
            Reporter:
            richtea Richard Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes