[Development] Qt's generated cmake files
Sascha Cunz
sascha-ml at babbelbox.org
Mon Feb 18 16:03:55 CET 2013
On Monday, February 18, 2013 07:18:44 AM Stephen Kelly wrote:
> On Monday, February 18, 2013 03:27:32 Sascha Cunz wrote:
> > I am using FIND_PACKAGE and QT_USE_MODULES in each subdirectory of
> > my cmake source tree like shown in [2]. This is required, because I have a
> > generic stub that encapsules the differences from Qt4/5 and use that in
> > several different projects. So i actually don't know in advance what git
> > submodules are in use and what Qt modules they depend on.
>
> Hi there,
>
> You seem to be doing some things which are not recommended. You shouldn't be
> starting with finding qmake
Maybe things changed since I set this up, but I never got this to work
reliable without appending the cmake_prefix.
I.e.: On windows I might have installed Qt to X:\Qt5\bin - how would cmake
know that I installed Qt there, unless I append the prefix path?
Considering the smallness of most of my projects, when something goes wrong
that is not easily explained, "probably caused by invalid build" or when
switching platforms, i tend to completely remove my build directory and do a
fresh cmake run followed by a full build. As I don't want to populate the
cache every time, I settled on searching for qmake in $path and append the
cmake_prefix_path with qt's install path.
Isn't this a valid approach? What would be better yet still that simple?
> and you shouldn't include() the config files directly. Using include()
> directly is likely to have unintended consequences.
Ah, I see. Will try that.
> The appropriate way to write an umbrella infrastructure is
> something like what is in these files:
>
> http://quickgit.kde.org/index.php?p=extra-cmake-modules.git&a=blob&f=find-> modules%2FFindQt5Transitional.cmake
>
> http://quickgit.kde.org/index.php?p=extra-cmake-> modules.git&a=blob&f=modules%2FECMQt4To5Porting.cmake
>
> Why do you duplicate the RCC macro?
Just for one reason: To have a unique name with Qt4 and Qt5.
Actually, might as well be an "old habbit": In older projects I used to
duplicate the Qt-Macros in order to automatically group files into virtual
folders for Visual Studio projects.
But looking at this instance once again, I think you indeed have a point here:
I should just wrap the original in a macro.
> I just created a project which calls find_package(Qt5Core) in two
> subdirectories and uses Qt5Core_INCLUDE_DIRS, and it works for me. Please
> file a bug with a minimal testcase, preferably using find_package instead
> of include() as you do.
Thanks for your input. I will investigate this further based on your comments.
Sascha
More information about the Development
mailing list