Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-08 Thread Michael Hertling
On 06/07/2011 09:13 PM, Bjørn Forsman wrote:
> 2011/6/7 Michael Wild :
>> 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).
> 
> Ok, I see the point now. However, if find_package is called only in
> the subdirectories that actually need it the above problem is
> non-existent. No? (At least add_definitions only work on the current
> dir and below.) But if the policy is they way it is, then OK, I get
> the point and I'll leave it at that.

As you've said yourself in this thread earlier, FIND_PACKAGE()'s point
is to "set up variables containing necessary includes and libs" - and
nothing should happen behind your back. For this reason, I think that
FIND_PACKAGE() should be safe to invoke from *anywhere* in a project,
with results solely depending on the COMPONENTS, well-known variables
like CMAKE_PREFIX_PATH and well-documented ones like XXX_ROOT; taking
into account the results of previous FIND_PACKAGE() invocations might
have undesired effects, e.g. overlinking.

> However, according to Modules/readme.txt, FindXXX.cmake files should
> set XXX_LIBRARIES, XXX_INCLUDE_DIRS and XXX_DEFINITIONS. FindQt4.cmake
> sets neither. I can try to come up with a patch to fix this, but I
> won't complain if someone beats me to it ;-)

My suggestions for an improvement of FindQt4.cmake are:

1) Introduce symbolic names, e.g. QT_QT*_DEFINITIONS, for the modules'
preprocessor definitions like -DQT_*_LIB, so one has a chance to set
up a complete compilation environment w.r.t. Qt modules without the
need to include the QT_USE_FILE. This is important for find modules
using FindQt4.cmake and should be feasible without harming backward
compatibility.

2) Correct/complete the management of Qt's inter-module dependencies
and check if it can be added to FindQt4.cmake. AFAICS, it means no
harm if this is done in FindQt4.cmake, too, along with UseQt4.cmake.

3) Populate QT_{LIBRARIES,INCLUDE_DIRS,DEFINITIONS} with settings
according only to the COMPONENTS and their prerequisites, cf (2).
QT_INCLUDE_DIRS is new, i.e. no harm, and QT_LIBRARIES is reset by
UseQt4.cmake, so the latter's users should not see any differences
with regard to the current behavior. Admittedly, the enhancement of
QT_DEFINITIONS might result in some doublings among the preprocessor
definitions, but this should also mean no harm and could possibly be
taken into account by UseQt4.cmake. Alternatively, one might use the
variables QT4_{LIBRARIES,INCLUDE_DIRS,DEFINITIONS} for this purpose.
^
Regards,

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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-08 Thread Michael Hertling
On 06/07/2011 06:58 PM, Michael Wild wrote:
> On 06/07/2011 06:23 PM, Bjørn Forsman wrote:
>> 2011/6/7 Michael Wild :
>>> 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.

Michael, with your approach, i.e. a FIND_PACKAGE(Qt4) once in the top-
level CMakeLists.txt and INCLUDE(${QT_USE_FILE}) where needed, you've
to set up the required QT_USE_* variables each time, and possibly, you
must even unset some of them in case they are inherited from previous
actions like that. Is this really less effort than an additional call
to FIND_PACKAGE()? IMO, the latter is neater and more expressive, and
if FindQt4.cmake would provide the variables recommended by Modules/
readme.txt, i.e. QT_{LIBRARIES,INCLUDE_DIRS,DEFINITIONS}, one could
completely drop the QT_USE_FILE and proceed as known from the
majority of packages.

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

Absolutely, but note that FindXXX.cmake is possibly used in other find
modules, so it must provide *complete* information to set up the build
environment for XXX without a need to include UseXXX.cmake; otherwise,
the other package is forced to provide a use file, too, and this might
be inappropriate. The combination of {Find,Use}Qt4.cmake has such a
deficiency w.r.t. the QT_*_LIB preprocessor definitions.

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

As Marcus has pointed out in the meantime, this should carry no weight
due to the cache. Personally, I also prefer to have multiple calls to
FIND_PACKAGE(Qt4), once in each CMakeLists.txt that's using Qt, and I
place them after any ADD_SUBDIRECTORY() command unless I actually want
to convey the results to the subdirectories. IMO, this allows for good
locality and self-contained subprojects and minimizes the chance of
overlinking, but probably, it's a matter of taste.

Regards,

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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-08 Thread Michael Hertling
On 06/07/2011 02:20 PM, Bjørn Forsman wrote:
> Hi all,
> 
> As far as I can tell, all Qt programs built with CMake must include
> QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
> include QT_USE_FILE itself? Is there maybe a use case where
> QT_USE_FILE is *not* wanted?

Yes, there is: Suppose there is a tiny library package X which uses
Qt's signal/slot mechanism and, thus, must link against QtCore. X's
FindX.cmake or XConfig.cmake is expected to provide the variables
X_LIBRARIES, X_INCLUDE_DIRS and X_DEFINITIONS. While you can add
QT_QTCORE_LIBRARY to X_LIBRARIES and QT_QTCORE_INCLUDE_DIR to
X_INCLUDE_DIRS, how do you add the preprocessor definition for
the compilation with the QtCore headers, i.e. -DQT_CORE_LIB, to
X_DEFINITIONS? These definitions are hardcoded in QT_USE_FILE and
immediately enabled there via ADD_DEFINITIONS(). FindQt4.cmake does
not provide symbolic names for them, so you cannot set up a complete
compilation environment for Qt modules without including QT_USE_FILE,
and that's not allowed for find modules or config files as Michael W.
has pointed out in this thread earlier. The only possibilities for X
to allow its users to prepare a complete compilation environment are

1) either tell X's users to include QT_USE_FILE after FIND_PACKAGE(X)
when they want to use the X stuff ("Why do I have to include this
QT_USE_FILE thing when all I want is just using X? Strange...")

2) or provide an own X_USE_FILE which just includes QT_USE_FILE, and
tell X's users to include X_USE_FILE after FIND_PACKAGE(X) when they
want to use the X stuff ("Why do I have to bother with this USE_FILE
thing when I want to use a tiny package like X? I have already seen
more complex packages that don't require such hassle. Strange...").

Currently, the QT_USE_FILE is not just convenient, but *necessary* to
completely set up the compilation environment. IMO, that's wrong, in
particular as it is not only to be used in CMakeLists.txt files, but
also in other find modules and, possibly, configuration files.

There's another reason why QT_USE_FILE is somewhat essential to set
up the compilation environment: It cares for the Qt inter-module
dependencies. Look at the following example:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(QTMODDEPS C CXX)
SET(CMAKE_VERBOSE_MAKEFILE ON)
FIND_PACKAGE(Qt4 COMPONENTS QtSvg)
INCLUDE(${QT_USE_FILE})
FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
ADD_EXECUTABLE(main main.c)
TARGET_LINK_LIBRARIES(main ${QT_LIBRARIES})

It's QT_USE_FILE that enables Qt{Xml,Gui,Core} in the link command line
although only QtSvg has been requested. Therefore, if one doesn't want
to use QT_USE_FILE, one has to sort out these dependencies by oneself.
IMO, that's also wrong as I'd consider it to be the find module's job
to track dependencies among components requested with FIND_PACKAGE(),
not a USE_FILE's one. BTW, if you replace Svg by Sql in the example
above, you'll see that the main target is linked only against QtSql
although the latter does depend on QtCore. Obviously, QT_USE_FILE's
dependency management is not complete, so one should take care of
mentioning all necessary Qt modules in FIND_PACKAGE() by oneself.

Personally, I'd appreciate a FindQt4.cmake which

- completely and correctly tracks dependencies among the Qt modules,
- provides the usual variables QT_{LIBRARIES,INCLUDE_DIRS,DEFINITIONS},
- populates them with settings based on the COMPONENTS list passed to
  the FIND_PACKAGE(Qt4 ...) call and those components' prerequisites,
- does *not* take the results of previous FIND_PACKAGE(Qt4 ...) calls
  into consideration, i.e. does not act in an accumulative manner. So,
  the values of the QT_{LIBRARIES,INCLUDE_DIRS,DEFINITIONS} variables
  after a call to FIND_PACKAGE() do depend only on the COMPONENTS list
  passed to FIND_PACKAGE(), well-known variables as CMAKE_PREFIX_PATH
  and package-specific - documented - ones as QT_QMAKE_EXECUTABLE.

In this way, QT_USE_FILE would not be necessary anymore, and one could
invoke FIND_PACKAGE(Qt4 ...) multiple times and anywhere in a project
and gets exactly what has been requested without the risk of catching
unmeant results from previous FIND_PACKAGE(Qt4) invocations. Finally,
find modules may provide their users with complete information about
the compilation environment if their respective package uses Qt4.

Regards,

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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Bjørn Forsman
2011/6/7 Michael Wild :
> 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).

Ok, I see the point now. However, if find_package is called only in
the subdirectories that actually need it the above problem is
non-existent. No? (At least add_definitions only work on the current
dir and below.) But if the policy is they way it is, then OK, I get
the point and I'll leave it at that.

However, according to Modules/readme.txt, FindXXX.cmake files should
set XXX_LIBRARIES, XXX_INCLUDE_DIRS and XXX_DEFINITIONS. FindQt4.cmake
sets neither. I can try to come up with a patch to fix this, but I
won't complain if someone beats me to it ;-)

Best regards,
Bjørn Forsman
___
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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Marcus D. Hanwell
2011/6/7 Michael Wild :
> On 06/07/2011 06:23 PM, Bjørn Forsman wrote:
>> 2011/6/7 Michael Wild :
>>> 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.

Virtually everything is cached AFAIK, there is minimal cost in multiple calls.
>>
>>> 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).
>
It could perhaps go one step further and populate QT_LIBRARIES with
the requested components.
>>
>> 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.
>
Aren't they very minimal as they see that the variable is set and return?

Marcus
___
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


Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Bjørn Forsman
On 7 June 2011 16:32, Rolf Eike Beer  wrote:
>> Hi all,
>>
>> As far as I can tell, all Qt programs built with CMake must include
>> QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
>> include QT_USE_FILE itself? Is there maybe a use case where
>> QT_USE_FILE is *not* wanted?
>
> Besides the points already given here is another example:
>
> CMakeLists.txt:
>
> find_package(Qt4 REQUIRED)
> add_subdirectory(a)
> add_subdirectory(b)
>
> a/CMakeLists.txt
>
> SET(QT_DONT_USE_QTGUI TRUE)
> INCLUDE(${QT_USE_FILE})
> ...
> TARGET_LINK_LIBRARIES(foo ${QT_LIBRARIES})
>
> b/CMakeLists.txt
> INCLUDE(${QT_USE_FILE})
> ...
> TARGET_LINK_LIBRARIES(bar ${QT_LIBRARIES})
>
> So bar would get linked against QtGui, but foo not. And this all without
> fiddling with all the single Qt libraries and their dependencies.

I see. I want to do the same, but slightly more readable (IMHO). If
find_package also includes the use file we could do this:

CMakeLists.txt:

add_subdirectory(a)
add_subdirectory(b)

a/CMakeLists.txt

find_package(Qt4 COMPONENTS QtCore REQUIRED)
...
TARGET_LINK_LIBRARIES(foo ${QT_LIBRARIES})

b/CMakeLists.txt
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
...
TARGET_LINK_LIBRARIES(bar ${QT_LIBRARIES})


foo will be linked to QtCore and bar will be linked to QtCore+QtGui.

What do you think?
___
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


Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Bjørn Forsman
2011/6/7 Michael Wild :
>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
___
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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Rolf Eike Beer
> Hi all,
>
> As far as I can tell, all Qt programs built with CMake must include
> QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
> include QT_USE_FILE itself? Is there maybe a use case where
> QT_USE_FILE is *not* wanted?

Besides the points already given here is another example:

CMakeLists.txt:

find_package(Qt4 REQUIRED)
add_subdirectory(a)
add_subdirectory(b)

a/CMakeLists.txt

SET(QT_DONT_USE_QTGUI TRUE)
INCLUDE(${QT_USE_FILE})
...
TARGET_LINK_LIBRARIES(foo ${QT_LIBRARIES})

b/CMakeLists.txt
INCLUDE(${QT_USE_FILE})
...
TARGET_LINK_LIBRARIES(bar ${QT_LIBRARIES})

So bar would get linked against QtGui, but foo not. And this all without
fiddling with all the single Qt libraries and their dependencies.

Eike
___
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


Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Michael Wild
On 06/07/2011 04:11 PM, Marcus D. Hanwell wrote:
> On Tue, Jun 7, 2011 at 9:46 AM, Michael Wild  wrote:
>> On 06/07/2011 03:21 PM, John Drescher wrote:
 If you don't care for the macros and want to set up the
 include-directories and defines yourself, no. Also, it is common to
 find_package(Qt4) in the top-level CMakeLists.txt file, but then include
 QT_USE_FILE only in specific subdirectories, where Qt is actually used.

>>>
>>> I have started doing that in my projects. It cuts down on the
>>> unnecessary includes for subprojects that do not need Qt.
>>>
>>> John
>>
>>
>> Ah, this reminds me of one of the things on my wish list for FindQt4:
>> Modern Qt4 uses a Mac-framework compatible layout, such that in order to
>> e.g. include QObject header, you would do
>>
>> #include 
>>
>> If a project is using this include-practice, the module could cut down
>> considerably on include-paths. Also, it makes the framework detection
>> ugliness on Mac unnecessary.
>>
>> So, here my wish: similar to QT_USE_IMPORTED_TARGETS, introduce
>> QT_USE_FRAMEWORK_INCLUDES (or similar) which only adds the directory
>> containing all the QtCore, QtGui, QtXml, ... header directories to the
>> include-path.
>>
> You can already do this, and the explicit individual libraries are all
> found via the find_package call. I rarely include the use file in
> small projects, and have module/class style includes and link to the
> individual libraries. It does cut down significantly on the include
> paths too.
> 
> Marcus

That's not what I meant. I wanted to say that when I do

find_package(Qt4 COMPONENTS QtCore, QtGui, QtXml)
include(${QT_USE_FILE})

I don't want the following to happen:

include_directories(
  /usr/include/qt4
  /usr/include/qt4/QtCore
  /usr/include/qt4/QtGui
  /usr/include/qt4/QtXml)

I just want:

include_directories(/usr/include/qt4).

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


Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Marcus D. Hanwell
On Tue, Jun 7, 2011 at 9:46 AM, Michael Wild  wrote:
> On 06/07/2011 03:21 PM, John Drescher wrote:
>>> If you don't care for the macros and want to set up the
>>> include-directories and defines yourself, no. Also, it is common to
>>> find_package(Qt4) in the top-level CMakeLists.txt file, but then include
>>> QT_USE_FILE only in specific subdirectories, where Qt is actually used.
>>>
>>
>> I have started doing that in my projects. It cuts down on the
>> unnecessary includes for subprojects that do not need Qt.
>>
>> John
>
>
> Ah, this reminds me of one of the things on my wish list for FindQt4:
> Modern Qt4 uses a Mac-framework compatible layout, such that in order to
> e.g. include QObject header, you would do
>
> #include 
>
> If a project is using this include-practice, the module could cut down
> considerably on include-paths. Also, it makes the framework detection
> ugliness on Mac unnecessary.
>
> So, here my wish: similar to QT_USE_IMPORTED_TARGETS, introduce
> QT_USE_FRAMEWORK_INCLUDES (or similar) which only adds the directory
> containing all the QtCore, QtGui, QtXml, ... header directories to the
> include-path.
>
You can already do this, and the explicit individual libraries are all
found via the find_package call. I rarely include the use file in
small projects, and have module/class style includes and link to the
individual libraries. It does cut down significantly on the include
paths too.

Marcus
___
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


Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Michael Wild
On 06/07/2011 03:47 PM, Bjørn Forsman wrote:
> On 7 June 2011 15:21, John Drescher  wrote:
>>> If you don't care for the macros and want to set up the
>>> include-directories and defines yourself, no. Also, it is common to
>>> find_package(Qt4) in the top-level CMakeLists.txt file, but then include
>>> QT_USE_FILE only in specific subdirectories, where Qt is actually used.
>>>
>>
>> I have started doing that in my projects. It cuts down on the
>> unnecessary includes for subprojects that do not need Qt.
> 
> Isn't it be possible to call find_package(Qt4) only in sub-projects that use 
> Qt?
> 
> (Note to self: read up on cmake find_package() and scoping...)
> 
> Best regards,
> Bjørn Forsman

Also read http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/readme.txt.

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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Michael Wild
On 06/07/2011 03:38 PM, Bjørn Forsman wrote:
> Thanks for a quick reply!
> 
> On 7 June 2011 14:52, Michael Wild  wrote:
>> On 06/07/2011 02:20 PM, Bjørn Forsman wrote:
>>> As far as I can tell, all Qt programs built with CMake must include
>>> QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
>>> include QT_USE_FILE itself? Is there maybe a use case where
>>> QT_USE_FILE is *not* wanted?
>>
>> If you don't care for the macros and want to set up the
>> include-directories and defines yourself, no.
> 
> Ok, guess I haven't had any use for that so far. Examples of when it
> may be useful are welcome.
> 
> But, wait...isn't that the whole point of find_package()? To set up
> variables containing necessary includes and libs? It seems
> FindWt4.cmake is special in this case, needing one extra step.
> 
>> Also, it is common to
>> find_package(Qt4) in the top-level CMakeLists.txt file, but then include
>> QT_USE_FILE only in specific subdirectories, where Qt is actually used.
> 
> Why not put find_package(Qt4) in the sub directories where it is actually 
> used?
> 
> Best regards,
> Bjørn Forsman

And if it is used in multiple subdirectories?

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.

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.

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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Bjørn Forsman
On 7 June 2011 15:21, John Drescher  wrote:
>> If you don't care for the macros and want to set up the
>> include-directories and defines yourself, no. Also, it is common to
>> find_package(Qt4) in the top-level CMakeLists.txt file, but then include
>> QT_USE_FILE only in specific subdirectories, where Qt is actually used.
>>
>
> I have started doing that in my projects. It cuts down on the
> unnecessary includes for subprojects that do not need Qt.

Isn't it be possible to call find_package(Qt4) only in sub-projects that use Qt?

(Note to self: read up on cmake find_package() and scoping...)

Best regards,
Bjørn Forsman
___
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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Michael Wild
On 06/07/2011 03:21 PM, John Drescher wrote:
>> If you don't care for the macros and want to set up the
>> include-directories and defines yourself, no. Also, it is common to
>> find_package(Qt4) in the top-level CMakeLists.txt file, but then include
>> QT_USE_FILE only in specific subdirectories, where Qt is actually used.
>>
> 
> I have started doing that in my projects. It cuts down on the
> unnecessary includes for subprojects that do not need Qt.
> 
> John


Ah, this reminds me of one of the things on my wish list for FindQt4:
Modern Qt4 uses a Mac-framework compatible layout, such that in order to
e.g. include QObject header, you would do

#include 

If a project is using this include-practice, the module could cut down
considerably on include-paths. Also, it makes the framework detection
ugliness on Mac unnecessary.

So, here my wish: similar to QT_USE_IMPORTED_TARGETS, introduce
QT_USE_FRAMEWORK_INCLUDES (or similar) which only adds the directory
containing all the QtCore, QtGui, QtXml, ... header directories to the
include-path.

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


Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Bjørn Forsman
Thanks for a quick reply!

On 7 June 2011 14:52, Michael Wild  wrote:
> On 06/07/2011 02:20 PM, Bjørn Forsman wrote:
>> As far as I can tell, all Qt programs built with CMake must include
>> QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
>> include QT_USE_FILE itself? Is there maybe a use case where
>> QT_USE_FILE is *not* wanted?
>
> If you don't care for the macros and want to set up the
> include-directories and defines yourself, no.

Ok, guess I haven't had any use for that so far. Examples of when it
may be useful are welcome.

But, wait...isn't that the whole point of find_package()? To set up
variables containing necessary includes and libs? It seems
FindWt4.cmake is special in this case, needing one extra step.

> Also, it is common to
> find_package(Qt4) in the top-level CMakeLists.txt file, but then include
> QT_USE_FILE only in specific subdirectories, where Qt is actually used.

Why not put find_package(Qt4) in the sub directories where it is actually used?

Best regards,
Bjørn Forsman
___
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

Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread John Drescher
> If you don't care for the macros and want to set up the
> include-directories and defines yourself, no. Also, it is common to
> find_package(Qt4) in the top-level CMakeLists.txt file, but then include
> QT_USE_FILE only in specific subdirectories, where Qt is actually used.
>

I have started doing that in my projects. It cuts down on the
unnecessary includes for subprojects that do not need Qt.

John
___
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


Re: [CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Michael Wild
On 06/07/2011 02:20 PM, Bjørn Forsman wrote:
> Hi all,
> 
> As far as I can tell, all Qt programs built with CMake must include
> QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
> include QT_USE_FILE itself? Is there maybe a use case where
> QT_USE_FILE is *not* wanted?
> 
> Best regards,
> Bjørn Forsman

If you don't care for the macros and want to set up the
include-directories and defines yourself, no. Also, it is common to
find_package(Qt4) in the top-level CMakeLists.txt file, but then include
QT_USE_FILE only in specific subdirectories, where Qt is actually used.

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

[CMake] FindQt4.cmake to automatically include QT_USE_FILE?

2011-06-07 Thread Bjørn Forsman
Hi all,

As far as I can tell, all Qt programs built with CMake must include
QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
include QT_USE_FILE itself? Is there maybe a use case where
QT_USE_FILE is *not* wanted?

Best regards,
Bjørn Forsman
___
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