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

Invalid parse context in CMake project with source file specific flags

    XMLWordPrintable

Details

    • Linux/X11
    • 3581d1c5d (12.0)

    Description

       

      Given the following reduced / self-contained CMake-Project (CMakeLists.txt):

      cmake_minimum_required(VERSION 3.27.6)
      
      project(foo)
      
      set(CMAKE_CXX_STANDARD 20)
      
      set(CONTENT [[
      	#include <concepts>
      
      	template<typename T>
      		concept FooConcept = requires(T foo)
      	{
      		foo.bar();
      	};
      ]])
      
      file(WRITE foo.hpp "${CONTENT}")
      file(WRITE foo.cpp "#include \"foo.hpp\"")
      file(WRITE bar.c "void bar() {}")
      
      add_library(foo SHARED foo.cpp bar.c foo.hpp)
      
      set_property(SOURCE bar.c
      	APPEND
      	PROPERTY COMPILE_OPTIONS
      		-fno-fast-math
      )
      

       

      Opening foo.hpp in the IDE generates (among others) the code model error:

      Unknown type name 'concept'

       

      Inspecting the code models I see three contexts.

      I am not sure why three (I would have understood two).

      The context (which in my case is used by default) that presumably causes the issue lists the compiler flags:

      -g -fPIC -fno-fast-math

      Another context (which works correctly if selected manually) lists the flags:

      -DQT_QML_DEBUG -g -std=gnu++20 -fPIC

      A third context is for "C" and does not apply to foo.hpp.

      I would assume that the first context should not exist at all or should also include the `-std=gnu++20` flag.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cadam Cristian Adam
            ngladitz Nils Gladitz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes