[cmake-developers] [PATCH 3/3] FindQt4: document cross compilation

Pascal Bach pascal.bach at siemens.com
Wed Jul 29 10:59:57 EDT 2015


Hi Clint

Am 29.07.2015 um 16:47 schrieb Clinton Stimpson:
> On Wednesday, July 29, 2015 04:05:41 PM Pascal Bach wrote:
>> Hi Clint
>>
>> Am 29.07.2015 um 15:45 schrieb Clinton Stimpson:
>>> Hi Pascal,
>>>
>>> Thanks for the patches.
>>>
>>> Can you share with us why setting CMAKE_FIND_ROOT_PATH does not work, or
>>> how this new method compares?
>>>
>>> For example, in the toolchain file:
>>> SET(CMAKE_FIND_ROOT_PATH  /path/to/Qt ...)
>> The problem is how FindQt4 does find the locations using qmake.
>>
>> let's assume there are two sysroots one is /sysroots/x86_64 which contains
>> binaries usable on the host machine, and there is /sysroots/arm which
>> contains libraries for the target system. this are both set via:
>> set( CMAKE_FIND_ROOT_PATH /sysroots/arm /sysroots/x86_64    )
>> set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
>> set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
>> set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
>> set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
> Yes, this concern of 2 sysroots has been brought up before.  Thanks for 
> addressing this.
>
>> Here is what happens when only setting CMAKE_FIND_ROOT_PATH:
>>
>> 1. FindQt4 is trying to find the qmake executable. As there is no qmake in
>> /sysroots/arm (it would not be runnable on the host) it will find qmake
>> from the /sysroots/x86_64 directory. 2. FindQt4 is asking qmake for the
>> path to the Qt installation. As the qmake found is the one from
>> /sysroots/x86_64 it will point to the libraries from /sysroots/x86_64 which
>> will obviously not run on arm!
>>
>> Currently I didn't find a way to override this behaviour of FindQt4, except
>> by setting all the variables usually set by FindQt4 manually. It is usually
>> accepted to set some variables manually when doing cross compilation. With
>> this patchset I tried to reduce this variable to a minumum and let FindQt4
>> figure out the rest.
>>
>> The minimum variables required with the patch are:
>>
>> QT_BINARY_DIR is necessary to find the correct qmake
>> QT_LIBRARY_DIR is necessary to find the library directory
>> QT_INCLUDE_DIR is necessary to find the include directory (might be possible
>> to figure this out from QT_INCLUDE_DIR if some assumptions are made)
>> QT_MKSPECS_DIR necessary to have the correct prefixes (E in the case of
>> qt4-embedded).
>>
>>
>> I hope my explanation is clear. If there is a better way to achive this I'm
>> all ears.
>>
> I'm fine with this, and don't think it'll conflict with any other use cases.
I don't see a conflict either.
>
> However, I do think we should first document setting CMAKE_FIND_ROOT_PATH, then 
> afterwards document the other variables for those users which need more 
> control.  Does that sound reasonable?
I'm not sure I understand what you mean.
I think how to set CMAKE_FIND_ROOT_PATH is already documented in cmake.
 Are you suggesting extending the docuemntation of FindQt4below with a paragraph documenting how to work with two sysroots?
With an example like this?

set( CMAKE_FIND_ROOT_PATH /sysroots/arm /sysroots/x86_64    )
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

Pascal
>
> Clint
>
>> Pascal
>>
>>> Clint
>>>
>>> On Wednesday, July 29, 2015 02:32:48 PM Pascal Bach wrote:
>>>> ---
>>>>
>>>>  Modules/FindQt4.cmake | 20 ++++++++++++++++++++
>>>>  1 file changed, 20 insertions(+)
>>>>
>>>> diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
>>>> index 9d03378..64c06e1 100644
>>>> --- a/Modules/FindQt4.cmake
>>>> +++ b/Modules/FindQt4.cmake
>>>> @@ -29,6 +29,26 @@
>>>>
>>>>  #  for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target
>>>>  #  property to ``TRUE`` on the executable.
>>>>  #
>>>>
>>>> +# Cross Compile
>>>> +# ^^^^^^^^^^^^^
>>>> +#
>>>> +# To find Qt in a cross compile environment set the following variables
>>>> in
>>>> your toolchain file: +#
>>>> +#
>>>> +# ``QT_BINARY_DIR``  => Path to native Qt binary directory
>>>> +# ``QT_LIBRARY_DIR`` => Path to target Qt library directory
>>>> +# ``QT_INCLUDE_DIR`` => Path to target Qt include directory
>>>> +# ``QT_MKSPECS_DIR`` => Path to target Qt mkspecs directory
>>>> +
>>>> +# example
>>>> +#
>>>> +# ::
>>>> +#   set( QT_BINARY_DIR   /sysroots/x86_64-linux/usr/bin )
>>>> +#   set( QT_LIBRARY_DIR  /sysroots/arm/usr/lib )
>>>> +#   set( QT_INCLUDE_DIR  /sysroots/arm/usr/include/qtopia )
>>>> +#   set( QT_MKSPECS_DIR  /sysroots/arm/usr/share/qtopia/mkspecs )
>>>> +#
>>>> +#
>>>>
>>>>  # Qt Build Tools
>>>>  # ^^^^^^^^^^^^^^
>>>>  #



More information about the cmake-developers mailing list