[cmake-developers] CMAKE_INSTALL_PREFIX vs CMAKE_SYSROOT ?

Alexander Neundorf neundorf at kde.org
Wed Jul 3 15:33:36 EDT 2013


On Wednesday 03 July 2013, Stephen Kelly wrote:
> 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.

Not quite sure.
I tend to agree.

Different question: is CMAKE_FIND_ROOT_PATH actually still necessary ?
With a combination of CMAKE_SYSROOT and CMAKE_PREFIX_PATH most cases should be 
handled already.

> 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.

Then there would be two different install prefixes. Which would be used when ?

Alex



More information about the cmake-developers mailing list