On 06/07/2011 06:23 PM, Bjørn Forsman wrote:
> 2011/6/7 Michael Wild <them...@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).

Then you would need to call find_package in all the subdirectories, with
all the work that goes along with that.

> 
>> 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.

If the FindXXX.cmake file called add_definitions(),
include_directories() et al., that could be potentially harmful. Some
sources might required that some define is not set, or a wrong header
file might be #include'ed (thing of all the different X.h that exist).
FindXXX.cmake modules should just define a few variables, *not* change
the build system. That's the caller's responsibility, either by calling
the functions himself or by including the UseXXX.cmake (if provided).

> 
> 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 ;-)

In principle not, except that all these redundant find_path() and
find_library() calls will incur some slight overhead.


Michael

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to