[CMake] [Dev] CMake 2.5-20070519 and tool chain support

Trevor Kellaway tkellaway at asl-electronics.co.uk
Tue May 22 11:34:53 EDT 2007


Alex,

> So you are not only cross compiling, you are also using a 
> completely different toolchain. This means you have to write 
> a cmake file which sets all the required cmake variables for 
> this toolchain (like CMAKE_C_LINK_EXECUTABLE etc.). This 
> usually either goes into the SYSTEM-COMPILER.cmake or 
> SYSTEM.cmake file. The rules for the compiler can't go into 
> the toolchain file, because currently they will be 
> overwritten by CMakeGenericSystem.cmake and maybe in other 
> places. I could change it so that there it sets only if it is 
> not set yet, but it's not realistic do get this done for 
> *all* variables used somewhere in Modules/ . I have to check 
> whether that works if this is limited to the variables set in 
> CMakeGenericSystem.cmake .
>
> [...]
>
> Actually the CMAKE_TOOLCHAIN_FILE file doesn't do that much, 
> but I think requiring the user to give 4 or 5 parameters via 
> -D or by setting up the cache manually before would be not 
> user friendly.

Understood, this makes more sense (and is sort of how I'd split it out
already).


> > If I use the command line "CMake -G"NMake Makfiles"
> > -DCMAKE_TOOLCHAIN_FILE:string=Toolchain-Freescale-HC12 
> ..\..\source" 
> > and having set my PATH up to include a directory containing 
> > "Toolchain-Freescale-HC12.cmake" I was rather hoping CMake 
> would find 
> > this, but no. Trying 
> > "-DCMAKE_TOOLCHAIN_FILE:string=Toolchain-Freescale-HC12.cmake" also
> 
> I didn't test it yet under Windows, but actually relative 
> paths should work. 
> Does prepending ".\" help ?

I think you misunderstood me, the relative path to the source tree is
fine, it is the search for the contents of CMAKE_TOOLCHAIN_FILE
"Toolchain-Freescale-HC12" that only works with a full path.

I want to create a directory with multiple Toolchain-*-* in it and not
have to specify a full path on the CMake command line, and let CMake
process it as if the file was in the CModule directory.

So, what is the right way to add a new directory that CMake should
search and treat like the CModule directory?


> >  -- Check for working C compiler: C:/Program Files/Freescale/CW for 
> > HC12 V4.5/prog/chc12.exe -- broken
> 
> Is it this one ?

It takes the standard style "-I", where in the CMake modules does the
CModule directory include get generated? I couldn't find this.


> Can you please post a command line how to invoke the compiler 
> and how to pass a include dir to it ?

Let me try and have another go before posting anything.


> Ok, so this is a very "embedded" compiler. In this case you 
> have to preset some more variables in the toolchain file, 
> like CMAKE_C_COMPILER_WORKS to TRUE.

Understood, this is why I was setting these in my first attempt.

 - TrevK


More information about the CMake mailing list