QtCreator cannot find CMake conan dependency files when using Conan 2.24
-
I'm in the processes of trying to upgrade from
Conan 1.66toConan 2.24and while everything works perfectly fine when running a build on the command line withConan 2.24and opening the project inQtCreator(version 18.0.1) withConan 1.66, the build fails when trying to open my project inQtCreatorwithConan 2.24. The issue stems from aConandependency namedcmake-common, which is a shared project containing various reusableCMakescripts (no C++ code or binary elements as such). My project recipe listscmake-commonas a dependency, and I can see inQtCreatorthat it is successfully installed and pulled in, however when theCMakeconfiguration for my project itself runs, it fails because it cannot find the contents ofcmake-common.The recipe/package for
cmake-commonis setup largely in the same way as what can be seen here:class CmakeCommonRecipe(ConanFile): name = "cmake-common" version = "1.2.3" package_type = "build-scripts" generators = ["CMakeToolchain"] def package(self): copy(self, "*.cmake", self.source_folder, self.package_folder, keep_path=True) def package_info(self): self.cpp_info.builddirs = ["macros"]The consumer (my project in this case) then lists
cmake-common/1.2.3as atool_requiresdependency in its recipeclass MyProjectRecipe(ConanFile): name = "my-project" version = "1.2.3" settings = "os", "compiler", "build_type", "arch" options = {"shared": [True], "fPIC": [True, False]} default_options = {"shared": True, "fPIC": True} tool_requires = "cmake-common/0.0.1"and then accesses the
cmake-commoncontents in itsCMakeLists.txtcmake_minimum_required(VERSION 3.27.7) # cmake-common-macros.cmake is provided by cmake-common and contains a series of include(<file>) for # all of the other files that cmake-common contains. Thus, this is purely an entry point into cmake-common include(cmake-common-macros) # ... and so onAs mentioned, this works perfectly fine if running on the command like with
Conan 2.24(orConan 1.66for that matter), and when runningCMakeinQtCreatorwithConan 1.66, but fails inQtCreatorwhen running withConan 2.24:[cmake] CMake Error at CMakeLists.txt:3 (include): [cmake] include could not find requested file: [cmake] [cmake] cmake-common-macrosSince the entry
cmake-common-macroscannot be found, then of course none of the functions/macros my project tries to use thatcmake-commonprovides work either. I don't know why this would be...Any thoughts as to what could be going on? I don't think that there are any issues with either the
ConanorCMakescripts/configurations as those work elsewhere and do work withConan 1.66inQtCreator. Is there something that needs to be done to tellQtCreatorto includeConandependencies into its "CMake Path" or something like that?Note: I can successfully include the file if I provide the absolute path to it, however then it fails because it cannot find the nested file it tries to include as those are also included as a relative path.
-
I'm in the processes of trying to upgrade from
Conan 1.66toConan 2.24and while everything works perfectly fine when running a build on the command line withConan 2.24and opening the project inQtCreator(version 18.0.1) withConan 1.66, the build fails when trying to open my project inQtCreatorwithConan 2.24. The issue stems from aConandependency namedcmake-common, which is a shared project containing various reusableCMakescripts (no C++ code or binary elements as such). My project recipe listscmake-commonas a dependency, and I can see inQtCreatorthat it is successfully installed and pulled in, however when theCMakeconfiguration for my project itself runs, it fails because it cannot find the contents ofcmake-common.The recipe/package for
cmake-commonis setup largely in the same way as what can be seen here:class CmakeCommonRecipe(ConanFile): name = "cmake-common" version = "1.2.3" package_type = "build-scripts" generators = ["CMakeToolchain"] def package(self): copy(self, "*.cmake", self.source_folder, self.package_folder, keep_path=True) def package_info(self): self.cpp_info.builddirs = ["macros"]The consumer (my project in this case) then lists
cmake-common/1.2.3as atool_requiresdependency in its recipeclass MyProjectRecipe(ConanFile): name = "my-project" version = "1.2.3" settings = "os", "compiler", "build_type", "arch" options = {"shared": [True], "fPIC": [True, False]} default_options = {"shared": True, "fPIC": True} tool_requires = "cmake-common/0.0.1"and then accesses the
cmake-commoncontents in itsCMakeLists.txtcmake_minimum_required(VERSION 3.27.7) # cmake-common-macros.cmake is provided by cmake-common and contains a series of include(<file>) for # all of the other files that cmake-common contains. Thus, this is purely an entry point into cmake-common include(cmake-common-macros) # ... and so onAs mentioned, this works perfectly fine if running on the command like with
Conan 2.24(orConan 1.66for that matter), and when runningCMakeinQtCreatorwithConan 1.66, but fails inQtCreatorwhen running withConan 2.24:[cmake] CMake Error at CMakeLists.txt:3 (include): [cmake] include could not find requested file: [cmake] [cmake] cmake-common-macrosSince the entry
cmake-common-macroscannot be found, then of course none of the functions/macros my project tries to use thatcmake-commonprovides work either. I don't know why this would be...Any thoughts as to what could be going on? I don't think that there are any issues with either the
ConanorCMakescripts/configurations as those work elsewhere and do work withConan 1.66inQtCreator. Is there something that needs to be done to tellQtCreatorto includeConandependencies into its "CMake Path" or something like that?Note: I can successfully include the file if I provide the absolute path to it, however then it fails because it cannot find the nested file it tries to include as those are also included as a relative path.
@cancech feel free to open a bug report and provide a small project that reproduces the issue. I will have a look there.
-
@cristian-adam Thanks, I'll try to open the bug report and a reproducing example later today.
For the time being we've been digging into this some more and while we're no closer to figuring out this issue, one question: Is there a difference in QtCreator in how it deals with
tool_requiresas compared torequires?In our situation we have a dependency on
FakeItand we can see that a number offakeit*.cmakefiles are created for it in theconan-dependency/*/generatorsdirectory byQtCreatorbut no such files are present forcmake-common(note, I'm also thinking that thesecmake-common.cmakefiles were created by Conan 1 but are no longer created by Conan 2 for some reason) -
@cristian-adam I've raised a bug report per your suggestion.
I added all of the relevant information into the report, but just as a follow-up here - while preparing the example reproducing the issue I found a potential hint as to what might be going on. Namely, it appears when then running with Conan 2 QtCreator appears to try and process the project
CMakeLists.txtbefore performing theconan install, thus theinclude(cmake-common-macros)is attempted before thecmake-commondependency providing it is made available. Or at least that's what appears to be going on. The output from the example shows theinclude(cmake-common-macros)as soon as I run CMake and only later in the output can I see that theconan installtakes place. -
@cristian-adam I've raised a bug report per your suggestion.
I added all of the relevant information into the report, but just as a follow-up here - while preparing the example reproducing the issue I found a potential hint as to what might be going on. Namely, it appears when then running with Conan 2 QtCreator appears to try and process the project
CMakeLists.txtbefore performing theconan install, thus theinclude(cmake-common-macros)is attempted before thecmake-commondependency providing it is made available. Or at least that's what appears to be going on. The output from the example shows theinclude(cmake-common-macros)as soon as I run CMake and only later in the output can I see that theconan installtakes place.@cancech Thank you for the bug report. I've updated the ticket with my thoughts.