[cmake-developers] Building with Qt for the Raspberry Pi with CMake

Alexander Neundorf neundorf at kde.org
Wed Apr 24 16:14:34 EDT 2013


On Wednesday 24 April 2013, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> > On Tuesday 16 April 2013, Stephen Kelly wrote:
> >> Alexander Neundorf wrote:
> >> > On Friday 12 April 2013, Stephen Kelly wrote:
> >> >> I found out what the problem is. CMake doesn't add the sysroot to the
> >> >> link line, so that's why the linker is not finding the library. It
> >> >> was searching in my native root and not finding them.
> >> >> 
> >> >>  set(CMAKE_CXX_LINK_FLAGS
> >> >>  
> >> >>    "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
> >> >> 
> >> >> Is there a reason CMake does not do something like the above already?
> >> > 
> >> > I don't think there's a reason that this is not done, except that
> >> > nobody has done it yet ;-)
> >> > So this should be somewhere inside a if(CMAKE_CROSSCOMPILING) in
> >> > Linux- GNU.cmake maybe ?
> >> 
> >> It needs special handling in c++ actually. I'll work on it. If
> >> CMAKE_FIND_ROOT_PATH can be a list, then we'll need a new variable like
> >> CMAKE_SYSROOT (which is also relevant to find_* commands) which is not a
> >> list.
> > 
> > That was the intention of CMAKE_FIND_ROOT_PATH, really.
> > When we added this in 2007, I think CMAKE_PREFIX_PATH did not exist yet
> > (this was still 2.4.x on the way to 2.6.0).
> > So CMAKE_FIND_ROOT_PATH had to be a list, the list of directories where
> > stuff for the target can be found.
> > Maybe today this could be done differently.
> > Let's say CMAKE_FIND_ROOT_PATH would be only one directory (sysroot),
> > which is set so that it points to the target file system hierarchy.
> 
> That raises backward compatibility questions. I'd rather not.
> 
> > The additional directories which need to be searched could today maybe
> > also be listed in CMAKE_PREFIX_PATH.
> 
> I have my rootfs at /home/stephen/rpi/rasp-pi-rootfs. That's what I use for
> my syroot.
> 
> I might also want to put KArchive in /opt/kf5/ on the target fs. So I'd
> additionally add /home/stephen/rpi/rasp-pi-rootfs/opt/kf5/ to the
> CMAKE_FIND_ROOT_PATHS.

Hmm, it works, but it is not really how it is supposed to be used.
CMake will then search in all default directories under 
/home/stephen/rpi/rasp-pi-rootfs/ and also in all default directories 
under/home/stephen/rpi/rasp-pi-rootfs/opt/kf5/ e.g. in /home/stephen/rpi/rasp-
pi-rootfs/usr/local/, and also in /home/stephen/rpi/rasp-pi-
rootfs/opt/kf5/usr/local/.

Would this also work if you set CMAKE_FIND_ROOT_PATH to 
/home/stephen/rpi/rasp-pi-rootfs/ and CMAKE_PREFIX_PATH to /opt/kf5/ ?


> I pushed a set-sysroot branch implementing this to my clone. This actually
> also makes it possible to cross-compile for android without forcing the
> compiler.

Cool :-)

Alex



More information about the cmake-developers mailing list