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

"conan install ..." during CMake fails with "ConanException: CMakeDeps is declared in the generators.."

    XMLWordPrintable

Details

    • 2103a9a77 (15.0)

    Description

      User described following bug for Conan Plugin: "Conan (experimental):
      "
      To reproduce, you need to have the conan package manger installed (see https://docs.conan.io/2/installation.html)

      Once installed, ensure that in QtCreator Preferences, under CMake, the check box "Package Manager Auto Setup" is checked.

      • Reproduce *

      On the command line, create a new cmake_exe Project via conan:

      mkdir demo
      cd demo
      conan new cmake_exe -d name=demo -d version=1.

      In QtCreator open .../demo/CMakeLists.txt, in the Projects View right click on the project "demo" and select "Run CMake".

      Result: the following error is printed in the General Messages window:
      [cmake] ERROR: conanfile.py (demo/1.0): Error in generate() method, line 28
      [cmake] deps.generate()
      [cmake] ConanException: CMakeDeps is declared in the generators attribute, but was instantiated in the generate() method too. It should only be present in one of them.

      For some reason it seems that when this conanfile.py is processed in function generate() the object self.generators contains an entry "CMakeDeps" although there is no place in the conanfile where this would have occurred.
      "

      User has also found a workaround:
      "
      We found a workaround for the problem: It is possible to detect whether Conan was invoked from Qt Creator using environment Variable "QTC_RUN". When that is the case we can clear the "generators" variable, then the error does not appear.

      def generate(self):
      if getenv("QTC_RUN"):
      self.output.highlight("Running within Qt Creator – deploy workaround")
      self.generators.clear()

      deps = CMakeDeps(self)
      deps.generate()
      tc = CMakeToolchain(self)
      tc.generate()
      "

      Attachments

        For Gerrit Dashboard: QTCREATORBUG-32076
        # Subject Branch Project Status CR V

        Activity

          People

            cadam Cristian Adam
            tero.pelkonen Tero Pelkonen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes