[CMake] how to use a cross linker

Alexander Neundorf a.neundorf-work at gmx.net
Fri Jun 15 08:36:14 EDT 2007


Hi,

On Friday 15 June 2007 02:54, kitts wrote:
...
> I cannot publish the source but let me describe how i do it now with my
> project at work.
>
> In the top level cmakelists.txt I include the subdirectories of the various
> modules in our project. The first subdirectory included is called platform.
>
> The platforms folder contains configuration details about a particular
> board that we support. This is the only information that is passed to CMake
> on the command (ex: -DPLATFORM=ABC). The configuration includes information
> on which compiler to use and which processor, the drives that are to be
> included and the modules that need to be included.

How do you do this ?
INCLUDE(${PLATFORM}) in your top level CMakeLists.txt ?

> The next directory that is included is the arch directory. This directory's
> cmakelists.txt sets up the compiler settings and the arch and variant
> specific defines and flags. Here it builds a libray called "hal".
>
> Now all other folders contain the various modules we support by building a
> library for each module that was selected for the platform.
>
> With this approach the problems i have are such:
> 1) Not always are settings made in a sub folder applied throughout the
> project. Especially settings wrt to library prefix and suffix.

This shouldn't be a problem with the approach in CMake cvs.
But it will not be possible to switch between different toolchains within one 
buildtree, this would break too much (e.g. all 
TRY_COMPILE()/TRY_RUN()/FIND_XXX() tests)

> 2) Setting up an assembler. We invariably need assembly file support when
> dealing with embedded systems.

Ok.
How do you do this currently ?

> 3) When setting up the build environment for the first time, cmake needs to
> be called from the shell as we need to pass -DPLATFORM=ABC. If we dont the
> compiler gets set to the system default and that cannot be changed. 

This won't change (except that this parameter is currently called 
CMAKE_TOOLCHAIN_FILE, maybe I'll rename it to CMAKE_TOOLCHAIN, since that's 
shorter). 

> 4) calling PROJECT() seems to destroy a lot of settings already configured.
> If called before making custom settings the compiler is set and cannot be
> changed...

Changing the compiler from within a cmake file is not really supported. This 
means you can do it but it's not the "official" way.

Bye
Alex


More information about the CMake mailing list