[cmake-developers] CMAKE_INSTALL_PREFIX vs CMAKE_SYSROOT ?

Stephen Kelly steveire at gmail.com
Wed Jul 3 11:12:17 EDT 2013


Hi there,

Given a generic toolchain file like this:

 
 set(CMAKE_SYSTEM_NAME Linux)

 set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc")
 set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++")

 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


I can invoke cmake like this:

 cmake .. -DCMAKE_TOOLCHAIN_FILE=../ArmToolchain.cmake \
  -DCMAKE_SYSROOT=/home/stephen/rpi/rasp-pi-rootfs/ \
  -DCMAKE_MAKE_PROGRAM=/usr/bin/make \
  -DCMAKE_INSTALL_PREFIX=/opt/myproject


Question: Should the installation be to 

 /opt/myproject 

on the host, or to 

 /home/stephen/rpi/rasp-pi-rootfs/opt/myproject

on the host?

For the Qt configure, the answer is the latter, and I think it makes sense. 
As CMAKE_SYSROOT is new, we can still change the behavior to that. I tend to 
think we should.

However, that leaves the question of how to install outside the sysroot. An 
option would be something like a new CMAKE_HOST_INSTALL_PREFIX:

 cmake .. -DCMAKE_TOOLCHAIN_FILE=../ArmToolchain.cmake \
  -DCMAKE_SYSROOT=/home/stephen/rpi/rasp-pi-rootfs/ \
  -DCMAKE_MAKE_PROGRAM=/usr/bin/make \
  -DCMAKE_HOST_INSTALL_PREFIX=/opt/myproject

which installs to 

 /opt/myproject

on the host.

This is the subject of a patch to Qt:

 https://codereview.qt-project.org/#change,59009

This is useful because I've done embedded development where I created an NFS 
mount in the host and mounted it in the target. Then I can make install on 
the host and can quickly and easily use the result on the target, which 
still has correct RPATH information etc.

Comments?

Thanks,

Steve.





More information about the cmake-developers mailing list