[CMake] Set CMAKE_TOOLCHAIN_FILE from cmake-gui

Alexander Neundorf a.neundorf-work at gmx.net
Fri May 29 15:53:31 EDT 2009


On Tuesday 26 May 2009, Roland Waltersson wrote:
> Hi,
> I am trying to get a user to choose target from cmake-gui, with:
>
> SET(TARGET "x86" CACHE STRING "Target (x86 or arm)")
> #some code here to construct CMAKE_TOOLCHAIN_FILE from TARGET variable
>
> This however don't work as the compiler settings are initialized when
> cmake-gui starts, not when the user presses Generate. So changing TARGET
> won't have any effect, except by chaning its default value.
>
> I have solved this now by instead using an .sh file to invoke cmake, but I
> would really like to be able to change this via cmake-gui. Is it even
> possible? thanks in advance!

The very first thing cmake does is to determine that target system type. 
There the first step is to laod the toolchain file. 
If this file is loaded any later, it is already too late.

cmake-gui has some support for cross compiling, i.e. in the configure-step you 
can choose cross compiling and then it asks you for the toolchain file.

Alex


More information about the CMake mailing list