Using Conan for Qt6: Difference between revisions
No edit summary |
No edit summary |
||
| Line 58: | Line 58: | ||
target_link_libraries(QtMPConsumerApp PRIVATE Qt::Widgets Qt::NetworkAuth) | target_link_libraries(QtMPConsumerApp PRIVATE Qt::Widgets Qt::NetworkAuth) | ||
* Alternative for using "conan_cmake_run()" in your CMakeLists.txt is to call conan(.exe) to build the required Add-on(s) | |||
** <QtSdk>/Tools/Conan/conan(.exe) install qtnetworkauth/6.0.0@qt/alpha --build=missing --profile=<QtSdk>/Tools/Conan/.conan/profiles/qt-6.0.0-linux -g cmake_paths (-g deploy) | |||
* Build 'MyApp' | * Build 'MyApp' | ||
** $ cd myapp | ** $ cd myapp | ||
** $ mkdir build && cd build | ** $ mkdir build && cd build | ||
** $ <QtSdk>/6.0.0/gcc_64/bin/'''qt-cmake''' '''-GNinja''' -DCMAKE_BUILD_TYPE=Release .. | ** $ <QtSdk>/6.0.0/gcc_64/bin/'''qt-cmake''' '''-GNinja''' -DCMAKE_BUILD_TYPE=Release .. | ||
*** this triggers Conan to build the qtnetworkauth (defined by REQUIRES) | *** this triggers Conan to build the qtnetworkauth (defined by REQUIRES) if conan_cmake_run() is used in your CMakeLists.txt | ||
** $ cmake --build . | ** $ cmake --build . | ||
** The MyApp should be in 'bin/* directory and you should be able to launch it | ** The MyApp should be in 'bin/* directory and you should be able to launch it | ||
Revision as of 06:48, 1 October 2020
"Work in Progress"
Qt6 Add-on src package build using Conan package manager
To build Qt6 Add-on src packages using Conan, which is provided by the Qt Installer, you can follow these steps. Note! This is still in alpha phase i.e. you may need workarounds to get it working and instructions may change later.
Linux
- Install required development libraries: https://doc-snapshots.qt.io/qt5-dev/linux-requirements.html
- Qt Installer - install:
- CMake (3.15 or higher is required)
- Conan (installs standalone conan(.exe) executable + settings files
- Ninja (CMake generator)
- 6.0.0 essentials binary package
- Add-on src package(s) needed in your CMake project
- Qt Installer provides Add-on packages under top-level "Additional libraries" node
- Put the installed tools into you PATH, prepend to PATH if needed to avoid mixing with older versions in your system
- <QtSdk>/Tools/CMake/bin
- <QtSdk>/Tools/Conan
- <QtSdk>/Tools/Ninja
- After installation of the 6.0.0 essentials binary package edit the following file: '<QtSdk>/6.0.0/gcc_64/lib/cmake/Qt6/qt.toolchain.cmake'
- Comment out the two first lines (the paths refer to the CI build environment)
- TODO: This step is not required after a patch to qtbase <https://codereview.qt-project.org/c/qt/qtbase/+/313965> lands into 6.0.0 snapshots
- Edit the CMakeLists.txt of your project
# Pick the correct conan profile matching the Qt build configuration (defines target build configuration)
set(ENV{CONAN_DEFAULT_PROFILE_PATH} "<QtSdk>/Tools/Conan/.conan/profiles/qt-6.0.0-linux")
# implements the conan_cmake_run() used below
include(<QtSdk>/Tools/Conan/conan.cmake)
conan_cmake_run(REQUIRES qtnetworkauth/6.0.0@qt/final
BASIC_SETUP
CMAKE_TARGETS
GENERATORS cmake_paths deploy # use 'deploy' generator if you want to export build artifacts from conan's cache to current working directory
PROFILE_AUTO build_type # build_type automatically detected by CMake (Release, Debug, ..)
#PROFILE_AUTO ALL # ALL value is used to use all detected settings from CMake
BUILD missing)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
find_package(Qt6 COMPONENTS Widgets Network) find_package(Qt6NetworkAuth)
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(QtMPConsumerApp PRIVATE Qt::Widgets Qt::NetworkAuth)
- Alternative for using "conan_cmake_run()" in your CMakeLists.txt is to call conan(.exe) to build the required Add-on(s)
- <QtSdk>/Tools/Conan/conan(.exe) install qtnetworkauth/6.0.0@qt/alpha --build=missing --profile=<QtSdk>/Tools/Conan/.conan/profiles/qt-6.0.0-linux -g cmake_paths (-g deploy)
- Build 'MyApp'
- $ cd myapp
- $ mkdir build && cd build
- $ <QtSdk>/6.0.0/gcc_64/bin/qt-cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..
- this triggers Conan to build the qtnetworkauth (defined by REQUIRES) if conan_cmake_run() is used in your CMakeLists.txt
- $ cmake --build .
- The MyApp should be in 'bin/* directory and you should be able to launch it
macOS
- Follow the same steps as for Linux above with the following changes
- Use <QtSdk>/6.0.0/clang_64/bin/qt-cmake
- set(ENV{CONAN_DEFAULT_PROFILE_PATH} "<QtSdk>/Tools/Conan/.conan/profiles/qt-6.0.0-macx-clang")
- export DYLD_FRAMEWORK_PATH with paths to 6.0.0 essentials & qtnetworkauth deploy directory
Windows (MSVC 2019 compiler)
- Follow the same steps as for Linux above with the following changes
- Open command prompt and execute vcvars64.bat
- "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
- Please note that Perl seems to be required also but not available from online installer at the moment.
- Add Qt binary folder into path
- path=<QtSdk>\6.0.0\msvc2019_64\bin;%PATH%
- set QT_CONAN_PROFILE=qt-6.0.0-msvc2019_64
Further notes
- Make sure the conan(.exe) provided by the Qt Installer is prepended into the PATH to avoid mixing it with system conan (if installed)
- Ninja is the recommended CMake generator and should be used. E.g. on Windows you may get compilation time errors if using VS generator