[CMake] Cross compiling arm-elf on Windows host

Alexander Neundorf a.neundorf-work at gmx.net
Mon Sep 21 12:03:40 EDT 2009


On Monday 21 September 2009, Harald Kipp wrote:
> Alexander Neundorf wrote:
> > On Sunday 20 September 2009, Harald Kipp wrote:
> >> Alexander Neundorf wrote:
> >>> On Sunday 20 September 2009, Harald Kipp wrote:
> >>>> add_library(nutfs STATIC basename dirent dirname)
> >
> > I would recommend to use the full filename, i.e. including the suffix. So
> > probably basename.c etc.
>
> Oops, I temporarily removed the extensions after finding make target
> extensions like .c.o.
>
> >>>>   Scanning dependencies of target nutfs
> >>>>   [ 33%] Building C object fs/CMakeFiles/nutfs.dir/basename.c.obj
> >>>>   Das System kann den angegebenen Pfad nicht finden.
> >>>
> >>> Try "VERBOSE=1 make" to see the full command which is executed.
> >>
> >> I'll try to do this tommorrow.
>
> As expected, make fails at the cd command using slashes instead of
> backslashes:
>
> [ 33%] Building C object fs/CMakeFiles/nutfs.dir/basename.c.obj
> cd C:/ethernut-4.9.6/nutbld/fs &&
> C:/Programme/yagarto/bin/arm-elf-gcc.exe    -o
> CMakeFiles/nutfs.dir/basename.c.obj   -c
> C:/ethernut-4.9.6/nut/fs/basename.c Das System kann den angegebenen Pfad
> nicht finden.
>
>   (English: The system cannot find the specified path)

Is this the make from yagarto ?

> make[2]: *** [fs/CMakeFiles/nutfs.dir/basename.c.obj] Error 1
> make[2]: Leaving directory `C:/ethernut-4.9.6/nutbld'
> make[1]: *** [fs/CMakeFiles/nutfs.dir/all] Error 2
> make[1]: Leaving directory `C:/ethernut-4.9.6/nutbld'
> make: *** [all] Error 2
>
> >>> You might try the nmake makefiles in case you have nmake.
> >>
> >> I'll try this as well.
>
> Unfortunately no luck. The generated Makefiles cannot be processed by
> GNU make, because nmake partly uses a different syntax, like
>
> !IF "$(OS)" == "Windows_NT"
> NULL=
> !ELSE
> NULL=nul
> !ENDIF
>
> Furthermore it adds the /nologo command line option when calling
> $(MAKE), which is rejected by GNU make.

Yes, you would have to use nmake to process these makefiles.

Which makefile generator do you use ?
"Unix Makefiles" ? There are also "MinGW Makefiles" and "MSYS Makefiles".
I don't have a Windows here, so I can't test.
These three generators all generate makefiles for GNU make under Windows, but 
differ in things like the directory separators etc.
From the docs for the MinGW one:
  "Generates a make file for use with mingw32-make.";
  "The makefiles generated use cmd.exe as the shell.  "
  "They do not require msys or a unix shell.";

and for the MSYS one:
  "Generates MSYS makefiles.";
  "The makefiles use /bin/sh as the shell.  "
  "They require msys to be installed on the machine.";

So the MSYS one is probably not what you want, but MinGW sounds good. Please 
give it a try.
So, you "only" have a problem with finding the right combination of makefile 
generator and build tools :-)
Here you can find a bit more information:
http://www.cmake.org/Wiki/CMake_Generator_Specific_Information#Makefile_generators


> >> One reason for looking at CMake as an alternative to GNU autotools is,
> >> that we do not want to force Windows users to install Cygwin or force OS
> >> X users to install fink. It'd be great if CMake can help here.
> >
> > Should do.
>
> Sigh. Right now I do not see the light at the end of the tunnel. May be
> I should explain my goal in more detail.
>
> Our package exists of the RTOS source code, which may be build for
> different targets (AVR, ARM, AVR32). Furthermore it contains the source
> code of the "Configurator" tool, which creates several C header files
> and Makefiles based on a target board config file. Running these
> makefiles will create the RTOS for this specific target board.
>
> Btw. the Configurator is based on the wxWidgets version of the eCos
> configtool, but we replaced tcl by Lua.
>
> On Linux and OS X we use GNU autotools to create the Configurator
> executable. On Windows there is no such capability and the average user
> must stick with the pre-build executable.
>
> Then the Configurator must be executed manually to create the header and
> Makefile files. Finally make will create the target binaries. These
> steps are equal on all host platforms.
>
> We could have used autotools to create the target binaries as well, but
> not on Windows without installing a *nix environment.
>
> The idea is to use CMake to automatically to
>
> 1. build the Configurator tool binary, checking the compiler available,
> wxWidgets version etc.

The first step must be separate from the two following, since it uses a 
different toolchain, and one buildtree in CMake must (really really should) 
use only one toolchain.

> 2. run the Configurator for a specified target board, creating the C
> headers and possibly one or more .cmake files for building the target
> binaries
>
> 3. build the RTOS and sample applications, checking the cross compiler,
> target run time library etc.

This should work.
We just need to get your makefiles work at all.

Alex


More information about the CMake mailing list