Qt Creator, CMakePresets and conan - can't use own conan profile
-
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.txtI'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 copyconan-dependencies/CMakeLists.txtinto 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?
-
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.txtI'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 copyconan-dependencies/CMakeLists.txtinto 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?
@SebastianM The code of
qtc_auto_setup_conanis located at here.You can create a
QtCreatorPackageManager.cmakefile 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.
-
I'll do so.
Bug reported.
-
For reference: That's QTCREATORBUG-34388 now.
-
One of solutions.
- Copy
c:\Qt\Tools\QtCreator\share\qtcreator\cmake-helper\conan_provider.cmaketo 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)
- Remove lines 616 and 645 (there're comments
- 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_PROFILEandCONAN_BUILD_PROFILEin selected configurationPreset
"cacheVariables": { "CONAN_HOST_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release", "CONAN_BUILD_PROFILE": "${sourceDir}/.conan/profiles/msvc_2019_release", - Copy
-
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 profileA 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}". -
S SebastianM has marked this topic as solved