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. Qt Creator, CMakePresets and conan - can't use own conan profile
Qt 6.11 is out! See what's new in the release blog

Qt Creator, CMakePresets and conan - can't use own conan profile

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 3 Posters 274 Views 1 Watching
  • 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.
  • SebastianMS Offline
    SebastianMS Offline
    SebastianM
    wrote last edited by
    #1

    Qt 6.7, Qt Creator v19, Windows 11.
    conanfile.py with description of required packages.
    I want Qt Creator to use conan profile present in repository folder, not default one.
    I added

    "CONAN_HOST_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release",
    "CONAN_BUILD_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release",
    

    to cacheVariables in one of configurationPresets. Then - in CMakeLists.txt - printed all variable with CONAN inside - and confirm that they are read correcty.
    Yet, Qt Creator repeatedly creates default profile and ignore mine.

    In <build_dir>\conan-dependencies\CMakeLists.txt I've noticed that ...

              conan_profile_detect_default()
              detect_host_profile("C:/dev/my_app/build_my_app_Qt_6.7_msvc2019_Release/conan-dependencies/conan_host_profile")
    
              set(build_types ${CMAKE_BUILD_TYPE})
              if (CMAKE_CONFIGURATION_TYPES)
                set(build_types ${CMAKE_CONFIGURATION_TYPES})
              endif()
    
              foreach(type ${build_types})
                conan_install(
                  -pr "C:/dev/my_app/build_my_app_Qt_6.7_msvc2019_Release/conan-dependencies/conan_host_profile"
                  --build=missing
                  -s build_type=${type}
                )
              endforeach()
    

    In other words - it ignores CONAN_HOST/BUILD_PROFILE variables.
    I tried to copy conan-dependencies/CMakeLists.txt into my repo as .conan/conan_provider.cmake, substitute -pr with explicit path and add "QT_CONAN_DEPENDENCIES_FILE": "${sourceDir}/.conan/conan_provider.cmake" to configurationPreset.
    Still, Qt Creator used the one generated by itself.

    How to tell Qt Creator to use my conan profiles?

    cristian-adamC 1 Reply Last reply
    0
    • SebastianMS SebastianM

      Qt 6.7, Qt Creator v19, Windows 11.
      conanfile.py with description of required packages.
      I want Qt Creator to use conan profile present in repository folder, not default one.
      I added

      "CONAN_HOST_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release",
      "CONAN_BUILD_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release",
      

      to cacheVariables in one of configurationPresets. Then - in CMakeLists.txt - printed all variable with CONAN inside - and confirm that they are read correcty.
      Yet, Qt Creator repeatedly creates default profile and ignore mine.

      In <build_dir>\conan-dependencies\CMakeLists.txt I've noticed that ...

                conan_profile_detect_default()
                detect_host_profile("C:/dev/my_app/build_my_app_Qt_6.7_msvc2019_Release/conan-dependencies/conan_host_profile")
      
                set(build_types ${CMAKE_BUILD_TYPE})
                if (CMAKE_CONFIGURATION_TYPES)
                  set(build_types ${CMAKE_CONFIGURATION_TYPES})
                endif()
      
                foreach(type ${build_types})
                  conan_install(
                    -pr "C:/dev/my_app/build_my_app_Qt_6.7_msvc2019_Release/conan-dependencies/conan_host_profile"
                    --build=missing
                    -s build_type=${type}
                  )
                endforeach()
      

      In other words - it ignores CONAN_HOST/BUILD_PROFILE variables.
      I tried to copy conan-dependencies/CMakeLists.txt into my repo as .conan/conan_provider.cmake, substitute -pr with explicit path and add "QT_CONAN_DEPENDENCIES_FILE": "${sourceDir}/.conan/conan_provider.cmake" to configurationPreset.
      Still, Qt Creator used the one generated by itself.

      How to tell Qt Creator to use my conan profiles?

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

      @SebastianM The code of qtc_auto_setup_conan is located at here.

      You can create a QtCreatorPackageManager.cmake file in your top source directory where you can:

      
      macro(myqtc_auto_setup_conan)
      # ...
      endmacro()
      myqtc_auto_setup_conan()
      
      set(QT_CREATOR_SKIP_CONAN_SETUP ON)
      

      But this copying the whole code. The better version would be to fix this case.

      Do create a Qt Creator bug with the details presented here.

      1 Reply Last reply
      2
      • SebastianMS Offline
        SebastianMS Offline
        SebastianM
        wrote last edited by SebastianM
        #3

        I'll do so.

        Bug reported.

        1 Reply Last reply
        2
        • aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote last edited by
          #4

          For reference: That's QTCREATORBUG-34388 now.

          Qt has to stay free or it will die.

          1 Reply Last reply
          1
          • SebastianMS Offline
            SebastianMS Offline
            SebastianM
            wrote last edited by
            #5

            One of solutions.

            • Copy c:\Qt\Tools\QtCreator\share\qtcreator\cmake-helper\conan_provider.cmake to eg. <build_dir>/conan/conan_provider.cmake.
            • Edit <build_dir>/conan/conan_provider.cmake
              • Remove lines 616 and 645 (there're comments not needed by Qt Creator, and if not commented it would break the auto-setup feature)
            • CMakePresets.json should contain
              • disable Package Manager Auto Setup
                  "qt.io/QtCreator/1.0": {
                    "PackageManagerAutoSetup": false,
                  }
              },
            
            • load modified conan_provider - add base configurationPreset
                {
                    "name": "conan-provider",
                    "hidden": true,
                    "cacheVariables": {   
                        "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/.conan/conan_provider.cmake"
                    }
                },
            
            • set CONAN_HOST_PROFILE and CONAN_BUILD_PROFILE in selected configurationPreset
                  "cacheVariables": {
                    "CONAN_HOST_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release",
                    "CONAN_BUILD_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release",
            
            1 Reply Last reply
            0
            • SebastianMS Offline
              SebastianMS Offline
              SebastianM
              wrote last edited by
              #6

              Update Qt Creator conan mechanism

              In file c:\Qt\Tools\QtCreator_v20\share\qtcreator\cmake-helper\package-manager.cmake
              in line 115 (file(WRITE "${CMAKE_BINARY_DIR}/conan-dependencies/CMakeLists.txt" ") generates CMakeLists.txt with hardcoded default profile

              A little bit higher

                    set(PROFILE_FILE "")
                    if (CONAN_HOST_PROFILE OR CONAN_BUILD_PROFILE)
                      if (CONAN_HOST_PROFILE)
                        set(PROFILE_FILE "${PROFILE_FILE} -pr:h \"${CONAN_HOST_PROFILE}\"")
                      endif()
                      if (CONAN_BUILD_PROFILE)
                        set(PROFILE_FILE "${PROFILE_FILE} -pr:b \"${CONAN_BUILD_PROFILE}\"")
                      endif()
                    else()
                      set(PROFILE_FILE "-pr:a \"${CMAKE_BINARY_DIR}/conan-dependencies/conan_host_profile\"")
                    endif()
              

              and substitute in line 134 (before adding above lines)
              from -pr \\"${CMAKE_BINARY_DIR}/conan-dependencies/conan_host_profile\\" to "${PROFILE_FILE}".

              1 Reply Last reply
              0
              • SebastianMS SebastianM has marked this topic as solved

              • Login

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