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

Trevor Kellaway tkellaway at asl-electronics.co.uk
Mon May 21 18:00:20 EDT 2007


Alex,

> > CMAKE_TOOLCHAIN_FILE that is in the current development CVS tree.

> - CMAKE_C_COMPILER - e.g. ppc_74xx-gcc
> - CMAKE_SYSTEM_NAME - e.g. "Linux"

OK, not sure I really understand the intention of CMAKE_SYSTEM_NAME, is
this the name of the system we are building on, or building for? For
embedded systems this doesn't really make sense, as most systems I work
on are totally bespoke.


Some stupid questions, concerning areas of CMake I haven't previously
had to use:

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
didn't work, much to my surprise, I had to use the full path. So, what
is the right way to add a new directory that CMake should search and
treat like the CModule directory?

I tried to ease the above situation by using a script to preload the
cache (I've previously used "CTest -S" for this for auto builds), with
"CMake -G"NMake Makefiles" -Cmycache.txt ..\..\source", where cache.txt
contains:

	SET (CMAKE_TOOLCHAIN_FILE
M:/Users/[...]/toolchain/Toolchain-Freescale-HC12.cmake)
	SET (CMAKE_C_COMPILER_ID_RUN:bool=TRUE)
	SET (CMAKE_C_COMPILER_WORKS:bool=TRUE)
	SET (CMAKE_SIZEOF_VOID_P=4)

Alas, this didn't work (I haven't got access to my Mastering CMake book
here, and couldn't find anything on the expected content for "-C" on the
Wiki).


Anyway, trying "cmake -G"NMake Makefiles"
-DCMAKE_TOOLCHAIN_FILE=M:\Users\[...]\toolchain\Toolchain-Freescale-HC12
.cmake ..\..\source" the compile of CMakeCCompilerId.c fails as
CMakePlatformId.h can't be found. How is the include path to the CModule
directory normally passed, surely via "<FLAGS>"?

To continue I kludged the CModule include path to be passed explicitly,
this produced:

 -- Check for working C compiler: C:/Program Files/Freescale/CW for HC12
V4.5/prog/chc12.exe -- broken

The link will fail, as mentioned before I have to include some extra
special support to make linking work (I could provide a default for this
purpose, but I wouldn't know when it should be used by a TRY-COMPILE
versus a real build when it shouldn't be included).

> In the toolchain file you can also set
> -CMAKE_SYSTEM_INFO_FILE - there you can adjust compiler 
> flags, commands etc. 

OK, you've confused me, I thought the compiler settings were meant to go
in CMAKE_TOOLCHAIN_FILE, what is the intention of
CMAKE_SYSTEM_INFO_FILE?

PS: I've written a number of Findxxx for our generic build system, and
I'm trying to extract all my CMake additions out into their own
directory, so I can easily update CMake with having to re-add all my
custom files.

 - TrevK


More information about the CMake mailing list