[CMake] FindQt4.cmake to automatically include QT_USE_FILE?

Bjørn Forsman bjorn.forsman at gmail.com
Tue Jun 7 12:23:04 EDT 2011


2011/6/7 Michael Wild <themiwi at gmail.com>:
>On 06/07/2011 03:38 PM, Bjørn Forsman wrote:
>> Why not put find_package(Qt4) in the sub directories where it is actually used?
>
> And if it is used in multiple subdirectories?

What's bad about that? (Sorry, I really don't know).

> FindXXX.cmake modules should only do the minimum, i.e. finding the
> required libraries and include-directories, setting XXX_FOUND,
> XXX_INCLUDE_DIRS and XXX_LIBRARIES. Anything more complex, e.g. calling
> add_definitions(), include_directories(), function(), macro() etc.
> should go into a UseXXX.cmake module.

Ok, I didn't know about that policy.

> If you find a FindXXX.cmake module that calls add_definitions(),
> include_directories(), link_libraries() or some such, it is broken and
> needs to be fixed.

Broken because of the above defined policy? Or of technical reasons?
Sorry, but I still don't see the reason why the current find_package +
use_file is better than a find_package that includes the use_file
itself.

What I see is that current usage goes something like this:

1) find_package(Qt4 REQUIRED) at the top level
2) subdirs that actually need Qt: set what modules to enable/disable
and then include the use_file.

How about doing it this way:
1) subdirs that actually need Qt: call find_package(Qt4 COMPONENTS
QtCore [...] REQUIRED) with the modules it needs.

Is there a problem with this approach? Other than breaking the policy ;-)

Best regards,
Bjørn Forsman


More information about the CMake mailing list