[CMake] FindQt4.cmake to automatically include QT_USE_FILE?

Michael Wild themiwi at gmail.com
Tue Jun 7 10:22:36 EDT 2011


On 06/07/2011 04:11 PM, Marcus D. Hanwell wrote:
> On Tue, Jun 7, 2011 at 9:46 AM, Michael Wild <themiwi at gmail.com> 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 <QtCore/QObject>
>>
>> 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


More information about the CMake mailing list