Jump to content

Using Conan for Qt6: Difference between revisions

From Qt Wiki
Iieklund (talk | contribs)
Iieklund (talk | contribs)
Line 59: Line 59:
You can pass each setting and option separately from command line or pass a build profile which should be more convenient way.
You can pass each setting and option separately from command line or pass a build profile which should be more convenient way.


* $ git clone "ssh://<user>@codereview.qt-project.org:29418/qt/qt5" && git checkout 6.2.0
*$ git clone "ssh://<user>@codereview.qt-project.org:29418/qt/qt5" && git checkout 6.2.0
** coin/conan/profiles/<pick suitable build configuration profile file>
**coin/conan/profiles/<pick suitable build configuration profile file>
* $ conan config install "ssh://<user>@codereview.qt-project.org:29418/qt/qt5" --args="-b other_branch" --source-folder=coin/conan/profiles --target-folder='''subdir'''
*$ conan config install "ssh://<user>@codereview.qt-project.org:29418/qt/qt5" --args="-b other_branch" --source-folder=coin/conan/profiles --target-folder='''subdir'''
** The --target-folder here points under your local Conan cache: $HOME/.conan/profiles/'''subdir'''
**The --target-folder here points under your local Conan cache: $HOME/.conan/profiles/'''subdir'''
* At the time of writing this is still a work in progress but should be available shortly:
*At the time of writing this is still a work in progress but should be available shortly:
** $ conan install qtbuildprofiles/6.2.0@qt/everywhere --build=missing --update -r qt
**$ conan install qtbuildprofiles/6.2.0@qt/everywhere --build=missing --update -r qt
*** the profiles are installed to the current directory
***the profiles are installed to the current directory


==Building==
==Building==
Line 114: Line 114:
***Launch your app..
***Launch your app..


=== Q/A: ===
===Q/A:===


* What Conan Settings?
*What Conan Settings?
** All the packages in the dependency chain will get the same Settings for binary compatibility (os, os version, arch, compiler, compiler version, ...)
**All the packages in the dependency chain will get the same Settings for binary compatibility (os, os version, arch, compiler, compiler version, ...)
** $HOME/.conan/settings.yml
**$HOME/.conan/settings.yml
*** This defines the project/organization level super-set of the supported settings
***This defines the project/organization level super-set of the supported settings
**** <nowiki>https://docs.conan.io/en/latest/reference/config_files/settings.yml.html</nowiki>  
****<nowiki>https://docs.conan.io/en/latest/reference/config_files/settings.yml.html</nowiki>
**** The Conan package build recipes usually reference the attributes from this file for various reasons
****The Conan package build recipes usually reference the attributes from this file for various reasons
**** This can be forked/edited but may then cause incompatibility between Qt packages and packages created by 3rd parties
****This can be forked/edited but may then cause incompatibility between Qt packages and packages created by 3rd parties
***** Current understanding is that we should try to stick with the upstream version of this file so our Qt packages are "compatible" with Conan packages in Conan Center Index (CCI)
*****Current understanding is that we should try to stick with the upstream version of this file so our Qt packages are "compatible" with Conan packages in Conan Center Index (CCI)
* What Conan Options? Where these are defined and what about Qt's configure options and features and leaf module features?
*What Conan Options? Where these are defined and what about Qt's configure options and features and leaf module features?
** qtbase:
**qtbase:
*** All configure options and features are mapped as Conan Options in the qtbase Conan package:
***All configure options and features are mapped as Conan Options in the qtbase Conan package:
**** $ conan '''inspect''' qtbase/6.2.0@qt/everywhere | grep headersclean  # grep if you want to narrow down the output
****$ conan '''inspect''' qtbase/6.2.0@qt/everywhere | grep headersclean  # grep if you want to narrow down the output
***** headersclean: ['yes', 'no', None]  # possible values headersclean: None  # default value
*****headersclean: ['yes', 'no', None]  # possible values headersclean: None  # default value
*** '''cmake_args_qtbase'''
***'''cmake_args_qtbase'''
**** Currently the only way to pass cmake arguments to qtbase build is via this Conan Option:
****Currently the only way to pass cmake arguments to qtbase build is via this Conan Option:
***** e.g. qtbase:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
*****e.g. qtbase:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
** leaf modules:
**leaf modules:
*** leaf module specific options are mapped as Conan Options per leaf module Conan package
***leaf module specific options are mapped as Conan Options per leaf module Conan package
**** $ conan '''inspect''' qtdeclarative/6.2.0@qt/everywhere
****$ conan '''inspect''' qtdeclarative/6.2.0@qt/everywhere
*** '''cmake_args_leaf_module'''
***'''cmake_args_leaf_module'''
**** Currently the only way to pass cmake arguments to leaf modules is via this Conan Option
****Currently the only way to pass cmake arguments to leaf modules is via this Conan Option
* I edited the profile file and tried to install pre-built Qt binaries but it fails/starts to compile from sources, why?
*I edited the profile file and tried to install pre-built Qt binaries but it fails/starts to compile from sources, why?
** Conan calculates a package_id checksum for each build configuration/binary package
**Conan calculates a package_id checksum for each build configuration/binary package
*** All the used Settings attribute values are included
***All the used Settings attribute values are included
*** All the used Options attribute values are included
***All the used Options attribute values are included
*** Check sums from all dependencies and transitive dependencies are included
***Check sums from all dependencies and transitive dependencies are included
** If you change the build profile or override the values from command line it will result in different package_id checksum -> Conan will interpret that such binaries are not available and tries to build from source (depending on used build policy)  
**If you change the build profile or override the values from command line it will result in different package_id checksum -> Conan will interpret that such binaries are not available and tries to build from source (depending on used build policy)  
*** '''Note! The following Options are explicitly excluded from package_id checksum calculation in Qt Conan package build recipes''':
***'''Note! The following Options are explicitly excluded from package_id checksum calculation in Qt Conan package build recipes as these should not affect binary compatibility''':
**** qtbase configure options:
****qtbase configure options:
***** sdk, android_sdk
*****sdk
***** android_ndk
*****android_sdk
***** android_ndk_platform
*****android_ndk
***** android_abis
*****android_ndk_platform
***** android_javac_target
*****android_abis
***** android_javac_source
*****android_javac_target
***** qpa, translationsdir
*****android_javac_source
***** headersclean
*****qpa, translationsdir
**** cmake arguments:
*****headersclean
***** CMAKE_CXX_COMPILER_LAUNCHER, CMAKE_C_COMPILER_LAUNCHER, QT_BUILD_EXAMPLES, WARNINGS_ARE_ERRORS, FEATURE_headersclean, PostgreSQL_ROOT, OPENSSL_ROOT_DIR, LLVM_INSTALL_DIR
****cmake arguments:
**** '''Example:'''
*****CMAKE_CXX_COMPILER_LAUNCHER
***** You want to install Qt6.2.0 binaries built by Qt using qt5.git:/coin/conan/profiles/linux-x86_64-gcc profile (used by Qt CI) but you notice that it has:  
*****CMAKE_C_COMPILER_LAUNCHER
****** qtbase:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOpenGL_GL_PREFERENCE=LEGACY -DFEATURE_system_harfbuzz=OFF -DOPENSSL_ROOT_DIR=$OPENSSL_ANDROID_HOME -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" *:cmake_args_leaf_module="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
*****QT_BUILD_EXAMPLES
***** You notice that is has certain options that would not work on your system. You can edit/remove the listed ones without affecting the package_id (binary compatibility):
*****WARNINGS_ARE_ERRORS
****** *:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOpenGL_GL_PREFERENCE=LEGACY -DFEATURE_system_harfbuzz=OFF -DOPENSSL_ROOT_DIR='''/my/openssl/dir''' " *:cmake_args_leaf_module=""
*****FEATURE_headersclean
*****PostgreSQL_ROOT
*****OPENSSL_ROOT_DIR
*****LLVM_INSTALL_DIR
****'''Example:'''
*****You want to install Qt6.2.0 binaries built by Qt using qt5.git:/coin/conan/profiles/linux-x86_64-gcc profile (used by Qt CI) but you notice that it has:  
******qtbase:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOpenGL_GL_PREFERENCE=LEGACY -DFEATURE_system_harfbuzz=OFF '''-DOPENSSL_ROOT_DIR=$OPENSSL_ANDROID_HOME''' '''-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache'''" *:cmake_args_leaf_module="'''-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache'''"
*****You notice that is has '''certain options''' that would not work on your system. You can edit/remove the <u>listed ones</u> without affecting the package_id (binary compatibility):
******<nowiki>*:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOpenGL_GL_PREFERENCE=LEGACY -DFEATURE_system_harfbuzz=OFF -DOPENSSL_ROOT_DIR=</nowiki>'''/my/openssl/dir''' " *:cmake_args_leaf_module=""
 
<nowiki/><nowiki/><nowiki/><nowiki/><nowiki/><nowiki/><nowiki/><nowiki/><nowiki/><nowiki/><nowiki/><code><nowiki/></code>


*
*
*
*
*
*
*Put the installed tools into your PATH, prepend to PATH if needed to avoid mixing with older versions in your system<syntaxhighlight lang="bash">
*
<QtSdk>/Tools/CMake/bin
*
<QtSdk>/Tools/Conan
<QtSdk>/Tools/Ninja
</syntaxhighlight>
*'''Build the Additional Library conan package'''
**The "conan(.exe) install" commands below will install the built binaries also to your current working directory so you may want to:
***mkdir '''<u>build_dir</u>''' && cd '''<u>build_dir</u>'''
**Windows '''MSVC2019''':
***For MSVC compiler open command prompt and execute vcvars64.bat
****e.g. <code>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat</code>
***<syntaxhighlight lang="bash" inline="">conan.exe install qtnetworkauth/6.0.0@qt/final --build=missing --profile=<QtSdk>/Tools/Conan/profiles/'''qt-6.0.0-msvc2019_64''' -s build_type=Release -g cmake_paths -g=cmake -g deploy</syntaxhighlight>
**Windows '''MinGW81''':
***For MinGW compiler add MinGW tools location to path
***<syntaxhighlight lang="bash" inline="">conan.exe install qtnetworkauth/6.0.0@qt/final --build=missing --profile=<QtSdk>/Tools/Conan/profiles/'''qt-6.0.0-mingw81_64''' -s build_type=Release -g cmake_paths -g=cmake -g deploy</syntaxhighlight>
**macOS '''clang'''
***<syntaxhighlight lang="bash" inline="">conan install qtnetworkauth/6.0.0@qt/final --build=missing --profile=<QtSdk>/Tools/Conan/profiles/'''qt-6.0.0-macx-clang''' -s build_type=Release -g cmake_paths -g=cmake -g deploy</syntaxhighlight>
**Linux '''gcc'''
***<syntaxhighlight lang="bash" inline="">conan install qtnetworkauth/6.0.0@qt/final --build=missing --profile=<QtSdk>/Tools/Conan/profiles/'''qt-6.0.0-gcc-x86_64''' -s build_type=Release -g cmake_paths -g=cmake -g deploy</syntaxhighlight>
**Currently the follwing Additional Libraries are available<nowiki/> as Conan packages:
***qtnetworkauth
***qtimageformats
***qt3d
**<nowiki/> The '''cmake_'''<nowiki/>'''paths''' generator w<nowiki/>ill produce ''''conan'''<nowiki/>'''_paths.cmake'''<nowiki/>' to your working directory, include it in your CMake project
**<nowiki/><nowiki/> If you have a '''qmake''' based consuming project for theAdditi<nowiki/>onal Library you can pass <code>-g qmake</code> -generator which will create ''''conanbu'''<nowiki/>'''ildinfo.pri'''<nowiki/>' file which you can include in your qmake project.  [https://docs.conan.io/en/latest/integrations/build_system/qmake.html https://docs.conan.io/en/latest/integrations/build_system][https://docs.conan.io/en/latest/integrations/build_system/qmake.html /qmake.html]
**Where the built binaries are?
***<code>$HOME/.conan/data/qtnetw<nowiki/>orkauth/6.0.0/qt/final/package'</code>
****<nowiki/> Note: If you have configured your Conan home/cache folder<nowiki/> differently the built package is located there
***When using a conan '''reference''' to install, i.e. "conan inst<nowiki/>all '''module/version@user/channel''' ..." conan will automatically deploy the binaries also to your current working directory:<syntaxhighlight lang="bash">
$PWD/include
$PWD/libs
$PWD/mkspecs
$PWD/modules
</syntaxhighlight>
***If using "-<nowiki/>g deploy" ge<nowiki/>nerator the bina<nowiki/>ries are exported to a sub-folder named by the module:<syntaxhighlight lang="bash">
$PWD/qtnetworkauth/include
$PWD/qtnetworkauth/lib
$PWD/qtnetworkauth/mkspecs
$PWD/qtnetworkauth/modules
</syntaxhighlight>
*'''Build the consuming project/app'''
**Edit the CMakeLists.txt of your MyApp project<syntaxhighlight lang="bash">
include(${CMAKE_BINARY_DIR}/conan_paths.cmake) # adjust the path for the "build_dir/conan_paths.cmake" in your env
..
..
find_package(Qt6 COMPONENTS Widgets Network REQUIRED)
find_package(Qt6 COMPONENTS NetworkAuth REQUIRED)
..
..
add_executable(MyApp main.cpp mainwindow.cpp mainwindow.h mainwindow.ui)
..
..
# Note! Temporary solution until fixed in Qt6 build system
foreach(prefix ${CMAKE_PREFIX_PATH})
    set(prefix_include "${prefix}/include")
        if(EXISTS "${prefix_include}")
            target_include_directories(MyApp PRIVATE "${prefix_include}")
        endif()
endforeach()
..
..
target_link_libraries(MyApp PRIVATE Qt::Widgets Qt::NetworkAuth)
</syntaxhighlight>
**Build 'MyApp'<syntaxhighlight lang="bash">cd myapp
mkdir build && cd build
cmake -G Ninja -D CMAKE_INSTALL_PREFIX=<QtSdk>/6.0.0/gcc_64 -DCMAKE_BUILD_TYPE=Release -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=path/to_your/'''<u>build_dir</u>''' ..
# Note: The "'''build_dir'''" is the root dir where conan deployed the built qtnetworkauth binaries in previous steps
cmake --build .
</syntaxhighlight>
***The MyApp should be in <code>bin/*</code> directory and you should be able to launch it
**Running the application
***The deploy generator <code>-g deploy</code> passed to conan deploys the build binaries from conan cache to your working directory
***Windows:
****Put the deployed binaries to the same directory of your built application
***macOS
****Put the deployed binaries to the same directory of your built application
****export DYLD_FRAMEWORK_PATH with paths to 6.0.0 essentials & qtnetworkauth deploy directory
***Linux:
****Put the deployed binaries to the same directory of your built application<br />
 
==Android builds==
If you are new to Android please check first instructions how to setup [https://doc.qt.io/qt-5/android-getting-started.html Android development environment].
 
There are some workarounds needed still for Android builds:
 
*You must use the following instead:<syntaxhighlight lang="bash">
find_package(Qt6NetworkAuth)
</syntaxhighlight>'''Note:''' QT_ADDITIONAL_PACKAGES_PREFIX_PATH does not work.
 
*Edit the CMakeLists.txt of your MyApp project<syntaxhighlight lang="bash">
include(/path/to/your/build_dir/conan_paths.cmake)
 
list(PREPEND CMAKE_FIND_ROOT_PATH "/path/to/your/build_dir/")
</syntaxhighlight>
 
*Build the project:
**Set the environment variables $ANDROID_SDK_ROOT and $ANDROID_NDK_ROOT to point to the Android SDK and NDK paths respectively.
**/path/to/your/qt_for_android/bin/qt-cmake(.bat) -GNinja -DCMAKE_BUILD_TYPE=Release -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT -DANDROID_NDK_ROOT=$ANDROID_NDK_ROOT
**cmake --build . --target apk
 
'''Note:''' androiddeployqt still cannot handle the Conan builds and cannot copy the modules' libraries to the android-build folder. As a workaround, the required libraries (*.so) can be copied manually to android-build/libs/<abi> for the apk to package them. For more updates, see [https://bugreports.qt.io/browse/QTBUG-88519 QTBUG-88519].
 
==Conan profiles for Qt packages==
The Qt Installer installs Conan profile files for those Qt essential binary packages that are selected for installation by the user.
 
The profile files are installed in: <QtSdk>/Tools/Conan/profiles
 
The profile files contain settings that match the configuration that was used to build the matching essentials binary package.
 
The [env] section contains 'QT_PATH' which points to the essentials package installation. This way the add-on Conan build recipe can locate the qt.toolchain.cmake file which is needed by the build recipe to build the Additional Library.
 
For Boot to Qt targets ('''Boot2Qt'''), the profiles do not have the QT_PATH env set and user needs to give this as environment variable when using conan (-e , --env) to point to the selected toolchain.
 
 
The profiles can be found from: https://code.qt.io/cgit/qt/qt-conan-config.git/ (https://codereview.qt-project.org/admin/repos/qt/qt-conan-config)
 
In case you want to install profiles by your self e.g. to some other location or you did not use Qt installer to install those you can use the following command:


- $conan config install <git-repo> -sf <path-in-git-repo> -tf <destination-path>
<br />


- e.g. $conan config install  <nowiki>git://code.qt.io/qt/qt-conan-config.git</nowiki> -sf profiles/qt/linux/6.0.0 -tf /home/<user>/temp_path
==Further notes==
==Further notes==


*Ninja is the recommended CMake generator and should be used. E.g. on Windows you may get compilation time errors if using VS generator
*Ninja is the recommended CMake generator and should be used. E.g. on Windows you may get compilation time errors if using VS generator

Revision as of 10:32, 7 October 2021

"Work in Progress"

Prerequisites

Conan depends on Python installed on your system. Although the Conan client may be standalone executable the Conan packages itself contain recipes that are written in Python.

  • Python 3.5 or higher
  • If you want to use Conan to build packages from sources
  • ICU
    • There is work in progress to bring ICU as Conan package(s) as a dependency to Qt packages so that it is taken care of automatically for the users (QTQAINFRA-4592). Until that one unfortunately needs to manually install ICU libs to system path where those can be found.
    • For example linux/macOS:
      • $ mkdir $HOME/icu_libs
      • $ cp $HOME/MyQtInstallation/6.2.0/gcc_64/lib/libicu* $HOME/icu_libs
      • export LD_LIBRARY_PATH=$HOME/icu_libs

Installing Conan

There are multiple options to install Conan package manager on your system:

Connecting to Conan remote

First you need credentials to Conan server. Login to your Qt Account and click on the "Conan Package Manager" link.

  • Click on the "Get a new password" link. These are your personal credentials to Conan remote.
  • Add Conan remote to your environment
    • $ conan remote add qt https://qtpkgtest.jfrog.io/artifactory/api/conan/qt
      • You can choose the alias name for the remote name
      • This will add it into $HOME/.conan/remotes.json
        • $ conan remote list
  • Authenticate to the server
    • $ conan user USERNAME -p PASSWORD -r qt
  • Run a search command to verify that your credentials and the remote were ok
    • $ conan search -r qt


Qt Conan packages

To get an idea what Qt Conan packages are available run the following command

  • $ conan search -r qt
    Existing package recipes:
    
    qtbase/6.2.0@qt/everywhere
    
    qtdeclarative/6.2.0@qt/everywhere
    
    qtimageformats/6.2.0@qt/everywhere
    
    qtmultimedia/6.2.0@qt/everywhere
    

The generic pattern for package naming is: <module name>/<version>-<pre-release segment>@qt/everywhere

  • Tome Qt .git repositories may yield multiple Conan packages like qtscxml.git -> qscxml, qtscxmlqml, qtscmlstatemachine and qtscxmlstatemachineqml
  • The optional pre-release segment may contain e.g. 6.2.0-alpha1, 6.2.0-beta2, 6.2.0-rc3

Build profiles

To tell Conan the build configuration you are interested about there are basically three ways (or four if you want to let Conan guess the default values).

You can pass each setting and option separately from command line or pass a build profile which should be more convenient way.

  • $ git clone "ssh://<user>@codereview.qt-project.org:29418/qt/qt5" && git checkout 6.2.0
    • coin/conan/profiles/<pick suitable build configuration profile file>
  • $ conan config install "ssh://<user>@codereview.qt-project.org:29418/qt/qt5" --args="-b other_branch" --source-folder=coin/conan/profiles --target-folder=subdir
    • The --target-folder here points under your local Conan cache: $HOME/.conan/profiles/subdir
  • At the time of writing this is still a work in progress but should be available shortly:
    • $ conan install qtbuildprofiles/6.2.0@qt/everywhere --build=missing --update -r qt
      • the profiles are installed to the current directory

Building

  • Next to your project/app create a file that declares the Qt library dependencies as Conan packages:
    • conanfile.txt:  # filename can be anything
      • [requires] qtbase/6.2.0@qt/everywhere qtdeclarative/6.2.0@qt/everywhere # what ever your project/app may require qtcharts/6.2.0@qt/everywhere
  • Call Conan to install the requirements for you (linux example):
    • $ conan install <path>/conanfile.txt --build=missing --profile=<profiles installation folder>/linux-x86_64-gcc --update --generator=virtualenv -r qt
      • --build
        • "--build" will force a complete build from sources including transitive dependencies
        • "--build=never" will attempt to install pre-built binaries (from local cache or from given server) if those should exist for the given build configuration i.e. --profile. If the requested build configuration is not found (local cache or server) Conan will bail out with an error
        • "--build=missing" Conan will attempt to build those missing packages/dependencies for the requested build configuration which are missing
        • https://docs.conan.io/en/latest/mastering/policies.html
      • --profile
        • This specifies the build configuration i.e. Conan settings (os, os version, compiler, arch, ...) and Options (shared, release, headersclean, ..)
          • Edit if needed
          • Settings and Options in profile file can be overridden from command line by:
            • -s compiler.version=9.3 -s compiler.libcxx=libstdc++11 -o release=no -o shared=no ...
      • --update
        • Forces Conan to check if the given server (-r, --remote) contains a newer version of the package(s) and downloads those if found. This option should be always preferred
      • --generator
        • multiple can be given
        • "--generator=virtualenv"
          • This will generate 'activate.sh'/'activate.ps1' which you can call
            • $ source activate.sh  # on windows do not use 'source' -command
          • Now all the Qt packages are in your PATH/env which were declared in the conaninfo.txt file
        • "--generator=qmake"
          • This will generate conanbuildinfo.pri file which you can include in your projects .pro file
      • -r, --remote
        • Ask Conan to install the package(s) from the given remote server to your local Conan cache
    • Note! If you want to export the binaries out from the Conan cache to given directory you need to call conan install a bit differently
      • $ conan install qtdeclarative/6.2.0@qt/everywhere --build=missing --profile=<profile> --update --install-folder=/home/<user>/Qt/6.2.0/gcc
        • You should have the binaries of the required package and all of its transitive dependencies installed to the given directory with the usual directory layout:
          • lib/
          • bin/
          • include/
          • ...
      • Note! If you call $conan install <path>/conanfile.txt ... args ... --install-folder=/foo Conan will export binaries from cache to separate sub-directories per dependency
        • /foo/qtbase/lib|bin|include|...
        • /foo/qtdeclarative/lib|bin|include|...
        • /foo/qtcharts/lib|bin|include|...
    • Activate the 'activate.sh/activate.ps1' and compile your project
      • $ source activate.sh # on windows just call the activate.ps1
      • $ cd your_project_path && mkdir build && cd build
      • $ cmake ../CMakeLists.txt
      • $ cmake --build ..
      • Launch your app..

Q/A:

  • What Conan Settings?
    • All the packages in the dependency chain will get the same Settings for binary compatibility (os, os version, arch, compiler, compiler version, ...)
    • $HOME/.conan/settings.yml
      • This defines the project/organization level super-set of the supported settings
        • https://docs.conan.io/en/latest/reference/config_files/settings.yml.html
        • The Conan package build recipes usually reference the attributes from this file for various reasons
        • This can be forked/edited but may then cause incompatibility between Qt packages and packages created by 3rd parties
          • Current understanding is that we should try to stick with the upstream version of this file so our Qt packages are "compatible" with Conan packages in Conan Center Index (CCI)
  • What Conan Options? Where these are defined and what about Qt's configure options and features and leaf module features?
    • qtbase:
      • All configure options and features are mapped as Conan Options in the qtbase Conan package:
        • $ conan inspect qtbase/6.2.0@qt/everywhere | grep headersclean  # grep if you want to narrow down the output
          • headersclean: ['yes', 'no', None]  # possible values headersclean: None  # default value
      • cmake_args_qtbase
        • Currently the only way to pass cmake arguments to qtbase build is via this Conan Option:
          • e.g. qtbase:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
    • leaf modules:
      • leaf module specific options are mapped as Conan Options per leaf module Conan package
        • $ conan inspect qtdeclarative/6.2.0@qt/everywhere
      • cmake_args_leaf_module
        • Currently the only way to pass cmake arguments to leaf modules is via this Conan Option
  • I edited the profile file and tried to install pre-built Qt binaries but it fails/starts to compile from sources, why?
    • Conan calculates a package_id checksum for each build configuration/binary package
      • All the used Settings attribute values are included
      • All the used Options attribute values are included
      • Check sums from all dependencies and transitive dependencies are included
    • If you change the build profile or override the values from command line it will result in different package_id checksum -> Conan will interpret that such binaries are not available and tries to build from source (depending on used build policy)
      • Note! The following Options are explicitly excluded from package_id checksum calculation in Qt Conan package build recipes as these should not affect binary compatibility:
        • qtbase configure options:
          • sdk
          • android_sdk
          • android_ndk
          • android_ndk_platform
          • android_abis
          • android_javac_target
          • android_javac_source
          • qpa, translationsdir
          • headersclean
        • cmake arguments:
          • CMAKE_CXX_COMPILER_LAUNCHER
          • CMAKE_C_COMPILER_LAUNCHER
          • QT_BUILD_EXAMPLES
          • WARNINGS_ARE_ERRORS
          • FEATURE_headersclean
          • PostgreSQL_ROOT
          • OPENSSL_ROOT_DIR
          • LLVM_INSTALL_DIR
        • Example:
          • You want to install Qt6.2.0 binaries built by Qt using qt5.git:/coin/conan/profiles/linux-x86_64-gcc profile (used by Qt CI) but you notice that it has:
            • qtbase:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOpenGL_GL_PREFERENCE=LEGACY -DFEATURE_system_harfbuzz=OFF -DOPENSSL_ROOT_DIR=$OPENSSL_ANDROID_HOME -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" *:cmake_args_leaf_module="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
          • You notice that is has certain options that would not work on your system. You can edit/remove the listed ones without affecting the package_id (binary compatibility):
            • *:cmake_args_qtbase="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOpenGL_GL_PREFERENCE=LEGACY -DFEATURE_system_harfbuzz=OFF -DOPENSSL_ROOT_DIR=/my/openssl/dir " *:cmake_args_leaf_module=""
<nowiki/>


Further notes

  • Ninja is the recommended CMake generator and should be used. E.g. on Windows you may get compilation time errors if using VS generator