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

Support for package manager dependency resolution

    XMLWordPrintable

Details

    Description

      As a user of a CMake I might have 3rd party packages that would be found by find_package

      CMake expects those packages to exist, with the use of a package manager they can be made available.

      Such a package manager could be conan, vcpkg or cpp-pm, but also a system package manager like apt, pkgcon or choco.

      Since CMake version 3.15 CMake provides the ability to inject a CMake script via CMAKE_PROJECT_INCLUDE_BEFORE variable.

      In such a script one could make sure that if conanfile.txt is present than conan install would be called, same for vcpkg.json with vcpkg install.

      The use case would be a Hello World application that uses fmt to print a message:

      #include <fmt/core.h>
      
      int main()
      {
          fmt::print("Привет мир\n");
          return 0;
      }

      And the CMakeLists.txt code for it:

      cmake_minimum_required(VERSION 3.15)
      
      project(hello-world LANGUAGES CXX)
      
      add_executable(hello-world main.cpp)
      
      find_package(fmt REQUIRED)
      target_link_libraries(hello-world PRIVATE fmt::fmt)
      

      A conanfile.txt would look like this:

      [requires]
      fmt/7.1.3 
      [generators]
      cmake_find_package
      

      A vcpkg.json would looke like this:

      {
        "name": "hello-world",
        "version-string": "0.0.1",
        "dependencies": [
          "fmt"
        ]
      }
      

      As a user I expect a project to load, compile successfully when the right setup with CMAKE_PROJECT_INCLUDE_BEFORE is setup.

      The custom script would be able to:

      • load QtCreatorPackageManager.cmake script found in the source directory
      • QT_CREATOR_SKIP_PACKAGE_MANAGER_SETUP would skip the whole auto-setup
      • QT_CREATOR_SKIP_CONAN_SETUP would skip the conan auto-setup
      • QT_CREATOR_SKIP_VCPKG_SETUP would skip the vcpkg auto-setup

      Attachments

        Issue Links

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

          Activity

            People

              cadam Cristian Adam
              cadam Cristian Adam
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes