[CMake] FindQt4.cmake returns too much irrelevant information

Mike Jackson mike.jackson at bluequartz.net
Fri May 8 13:31:35 EDT 2009


On Fri, May 8, 2009 at 12:07 PM, Clinton Stimpson <clinton at elemtech.com> wrote:
> Alan W. Irwin wrote:
>>
>> On 2009-05-07 22:45+0200 Christian Ehrlicher wrote:
>>
>>> Alan W. Irwin schrieb:
>>>>
>>>> I have just discovered that for -DCMAKE_BUILD_TYPE=Debug, the
>>>> combination of
>>>> FindQt4.cmake and UseQt4.cmake inserts the keywords debug, optimized,
>>>> AND
>>>> general into the QT_LIBRARIES list to divide the list into three
>>>> sections.
>>>> But only the debug section of that list is used by target_link_libraries
>>>> for
>>>> the -DCMAKE_BUILD_TYPE=Debug case.
>>>>
>>>> Could we have a cleaner design that doesn't specify the
>>>> target_link_libraries keywords and which simply returns in QT_LIBRARIES
>>>> whatever is relevant for the CMAKE_BUILD_TYPE that is specified?
>>>>
>>
>>
>>> CMAKE_BUILD_TYPE is not set for MSVC and other IDE generators so this
>>> will not work.
>>
>> I thought that was a good argument at first, but when I looked deeper it
>> turns out not to be relevant to this particular case since the setting of
>> the debug and optimized keywords in FindQt4.cmake occurs inside a
>>
>> IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
>>
>> logic block.
>>
>>
>>> This would also mean that you can't change the buildtype
>>> without doing a complete research of the existing libraries.
>>
>> I think that should be FindQt.cmake's job (i.e., return the correct
>> library
>> results depending on whether and how CMAKE_BUILD_TYPE is set). I think it
>> should be straightforward to avoid re-searching the libraries each time.
>> (Get cached library search results and return what is relevant depending
>> on
>> CMAKE_BUILD_TYPE.) Or did you mean something else?
>>
>>
>>> And CMAKE_BUILD_TYPE isn't use for some generators + is not set when you
>>> run cmake on a clean builddir without any options.
>>
>> Actually, I have no complaints about FindQt4.cmake when CMAKE_BUILD_TYPE
>> is
>> _not_ set.  But I do think it is a good idea to provide clean results when
>> CMAKE_BUILD_TYPE _is_ specified rather than a messy combination of
>> everything that _might_ be relevant.
>
> Its not clear to me how you'd make a .pc file for pkg-config for someone who
> chooses to build PLplot with a generator that ignores CMAKE_BUILD_TYPE.
> From what I can tell, it seems you're asking for a change to FindQt4.cmake
> to support making a CMakeLists.txt that is less-portable.
> Maybe we need another way to solve this?
>
> Clint
>

Don't forget that there are the following cmake variables after
FindQt4 has been run:

QT_QTCORE_LIBRARY
QT_QTCORE_LIBRARY_DEBUG
QT_QTCORE_LIBRARY_RELEASE

Repeated for each Qt library. Maybe you can use those variables in
your cmake code to copy the correct libraries. From what I have seen
the FindQt4 will do the "right thing" based on what is installed and
the value of CMAKE_BUILD_TYPE.

All you would have to supply would be the list of Qt libraries that
your program depends on.

Does this help at all?

Mike Jackson


More information about the CMake mailing list