Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator successful opens project with Conan 1.66 but not with Conan 2.24

QtCreator successful opens project with Conan 1.66 but not with Conan 2.24

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
conanconan 2qtcreator
3 Posts 2 Posters 143 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cancech
    wrote last edited by
    #1

    My project uses Conan for dependency management and CMake for build management/configuration; I can open said project in QtCreator (18.0.1) without any problems if I do so using Conan 1.66. I'm however in the process of switching to Conan 2, and the same project (no change in either code, CMake scripts, or Conan recipe) does not want to open if I try to open it using the latest Conan 2.24. There are no issues when trying to build the project from the command line using Conan (i.e.: conan install and conan create work perfectly with Conan 2.24 when run in the project folder), which make me think that there are no issues with either the CMake scripts or the Conan recipe.

    To avoid defining various shared values in both CMake and Conan, both are configured to load a project.details file located in the root of the project directory which contains project metadata that both require (such as project name and version). Conan is accessing it via the self.recipe_folder and CMake in the CMAKE_CURRENT_SOURCE_DIR. In a nutshell, this is ultimately the same thing as what the official Conan documentation shows for the set_name() method, albeit with some additional steps.

    As mentioned, this all works perfectly fine in QtCreator if I use Conan 1.66, or with Conan 2.24 if I perform a build via Conan on the command line (conan create .). However if I try to open this project in QtCreator with Conan 2.24 then I get the following error

    [cmake] ERROR: 
    [cmake] 	FileNotFoundError: [Errno 2] No such file or directory: 'C:/myproject/build/Desktop_Qt_6_9_3_MinGW_64_bit-Debug/conan-dependencies\\project.details'
    [cmake] CMake Error at C:/myproject/build/Desktop_Qt_6_9_3_MinGW_64_bit-Debug/.qtc/package-manager/conan_provider.cmake:463 (message):
    [cmake]   Conan install failed='1'
    [cmake] Call Stack (most recent call first):
    [cmake]   CMakeLists.txt:19 (conan_install)
    

    From what I can tell, this is due to QtCreator when using Conan 2.24 creating its own recipe_folder at <build_dir>/.qtc/package-manager and executing Conan from that directory rather than from within the project root. While the project's conanfile.py is copied over to the .qtc/package-manager directory, my custom project.details is not, thus the error. If up update my Conan recipe to load the project.details from the hard-coded absolute path the file is actually loaded in, it gets past this step.

    Is there a way to tell QtCreator to copy my project.details along with the conanfile.py when building its custom recipe_folder?

    The only other option I can think of would be to update the conanfile.py to load the file from the project root directory rather than recipe_folder, but I have not been able to find any reference to "project root" from within the Conan recipe.

    cristian-adamC 1 Reply Last reply
    0
    • C cancech

      My project uses Conan for dependency management and CMake for build management/configuration; I can open said project in QtCreator (18.0.1) without any problems if I do so using Conan 1.66. I'm however in the process of switching to Conan 2, and the same project (no change in either code, CMake scripts, or Conan recipe) does not want to open if I try to open it using the latest Conan 2.24. There are no issues when trying to build the project from the command line using Conan (i.e.: conan install and conan create work perfectly with Conan 2.24 when run in the project folder), which make me think that there are no issues with either the CMake scripts or the Conan recipe.

      To avoid defining various shared values in both CMake and Conan, both are configured to load a project.details file located in the root of the project directory which contains project metadata that both require (such as project name and version). Conan is accessing it via the self.recipe_folder and CMake in the CMAKE_CURRENT_SOURCE_DIR. In a nutshell, this is ultimately the same thing as what the official Conan documentation shows for the set_name() method, albeit with some additional steps.

      As mentioned, this all works perfectly fine in QtCreator if I use Conan 1.66, or with Conan 2.24 if I perform a build via Conan on the command line (conan create .). However if I try to open this project in QtCreator with Conan 2.24 then I get the following error

      [cmake] ERROR: 
      [cmake] 	FileNotFoundError: [Errno 2] No such file or directory: 'C:/myproject/build/Desktop_Qt_6_9_3_MinGW_64_bit-Debug/conan-dependencies\\project.details'
      [cmake] CMake Error at C:/myproject/build/Desktop_Qt_6_9_3_MinGW_64_bit-Debug/.qtc/package-manager/conan_provider.cmake:463 (message):
      [cmake]   Conan install failed='1'
      [cmake] Call Stack (most recent call first):
      [cmake]   CMakeLists.txt:19 (conan_install)
      

      From what I can tell, this is due to QtCreator when using Conan 2.24 creating its own recipe_folder at <build_dir>/.qtc/package-manager and executing Conan from that directory rather than from within the project root. While the project's conanfile.py is copied over to the .qtc/package-manager directory, my custom project.details is not, thus the error. If up update my Conan recipe to load the project.details from the hard-coded absolute path the file is actually loaded in, it gets past this step.

      Is there a way to tell QtCreator to copy my project.details along with the conanfile.py when building its custom recipe_folder?

      The only other option I can think of would be to update the conanfile.py to load the file from the project root directory rather than recipe_folder, but I have not been able to find any reference to "project root" from within the Conan recipe.

      cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote last edited by
      #2

      Qt Creator CMakeProjectManager's package manager auto-setup is trying to setup the environment where CMake can find packages and successfully configure the project.

      For conan a simple CMake probe project is set up which uses conan-cmake to do the conan install parts.

      It doesn't sound as project.details a standard Conan feature is.

      There is a customization point in the package-manager.cmake, at the top of the file:

      if (EXISTS "${CMAKE_SOURCE_DIR}/QtCreatorPackageManager.cmake")
        include("${CMAKE_SOURCE_DIR}/QtCreatorPackageManager.cmake")
      endif()
      

      You can create a QtCreatorPackageManager.cmake file where you have the statement:

      file(COPY "${CMAKE_CURRENT_LIST_DIR}/project.details" DESTINATION "${CMAKE_BINARY_DIR}/conan-dependencies/")
      
      1 Reply Last reply
      3
      • C cancech has marked this topic as solved
      • C Offline
        C Offline
        cancech
        wrote last edited by
        #3

        @cristian-adam Thank you so much! This solves my issue perfectly!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved