[CMake] cmake 2.5 with windows mobile

Alexander Neundorf a.neundorf-work at gmx.net
Mon Sep 17 10:05:53 EDT 2007


Hi Artur,

On Saturday 01 September 2007 06:16, Artur Wisz wrote:
> Alexander Neundorf wrote:
> > Why is this failing ?
> > It only tries to build an executable, it doesn't run it.
> >
> > Is the compiler called cl.exe or clarm.exe ?
> >
> > You need to setup a "toolchain file" as described here:
> > http://www.cmake.org/Wiki/CMake_Cross_Compiling
> >
> > It should contain
> > SET(CMAKE_SYSTEM_NAME Windows)
> > SET(CMAKE_C_COMPILER ...)
> > SET(CMAKE_CXX_COMPILER ...)
> >
> > This should be enough to get you over the first steps so a hello world
> > can be built.
> >
> > Windows-cl.cmake assumes that cl is the native compiler and so can be
> > only x86 32bit or x86 64bit.
> > Either this file has to be modified or a new platform "WindowsMobile" is
> > required. Is Windows Mobile a slimmed down version of XP or is it based
> > on Win CE ?
> >
> > Bye
> > Alex
>
> The compiler is cl.exe, so the same name as the native compiler.
> Windows Mobile is a new version of the Windows CE. WindowsMobile would
> be a good name for the target platform.

If it's a version of Win CE I'd suggest "WinCE" as name for the platform, so 
we don't end up with too many different platforms.

> This is the content of the CMakeError.log:
>
> "C:\Programme\CMake\share\cmake-2.5\Modules\CMakeCCompilerId.c" failed with
> the following output: 2
> Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50725 for ARM
> Copyright (C) Microsoft Corporation.  All rights reserved.
>
> CMakeCCompilerId.c
> Microsoft (R) Incremental Linker Version 8.00.50727.42
> Copyright (C) Microsoft Corporation.  All rights reserved.
>
> /out:CMakeCCompilerId.exe
> CMakeCCompilerId.obj
> LINK : fatal error LNK1104: cannot open file 'OLDNAMES.lib'
>
> When doing
>   set LINK=/NODEFAULTLIB:oldnames.lib /subsystem:windowsce,5.01 /DLL
> before running cmake, at least the custom platform file is scanned, but
> only when I run it under plain console (no vcvarsall.bat). I think there

Why doesn't it work with vcvarsall.bat ?

> should be a way to avoid setting LINK.
> So far my batch file looks like this:
>
> set PATH=C:\Programme\Microsoft Visual Studio 8\VC\ce\bin\x86_arm\;%PATH%
> set PATH=C:\Programme\Microsoft Visual Studio 8\Common7\IDE;%PATH%
> set INCLUDE=C:\Programme\Windows CE Tools\wce500\Windows Mobile 5.0
> Pocket PC SDK\Include\Armv4i;C:\Programme\Microsoft Visual Studio
> 8\VC\ce\atlmfc\include;C:\Programme\Microsoft Visual Studio 8\VC\ce\include
> set LIB=C:\Programme\Microsoft Visual Studio
> 8\VC\ce\lib\armv4i;C:\Programme\Windows CE Tools\wce500\Windows Mobile
> 5.0 Pocket PC SDK\Lib\ARMV4I
> set LINK=/NODEFAULTLIB:oldnames.lib /subsystem:windowsce,5.01 /DLL
> /NOLOGO coredll.lib corelibc.lib
>
> mkdir build-arm-wince-nmake
> cd build-arm-wince-nmake
> mkdir Debug
> cd Debug
>
> cmake -DCMAKE_MODULE_PATH=%CD%\..\..\..\config\cmake
> -DCMAKE_TOOLCHAIN_FILE=%CD%\..\..\..\config\cmake\toolchain-visual-wince.cm
>ake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%CD%\..\..\..\arm-wince
> -DTARGET_PLATFORM=arm-wince -G "NMake Makefiles" ..\..

With -D you are setting cmake variables, so they should have cmake-style 
paths, i.e. using forward slashes. This should fix your problem below.
What do you use TARGET_PLATFORM for ?

> The toolchain file:
>
> MESSAGE(STATUS "Took toolchain-visual")
> SET(CMAKE_SYSTEM_NAME WindowsMobile)
> # which C and C++ compiler to use
> SET(CMAKE_C_COMPILER   "/Programme/Microsoft Visual Studio
> 8/VC/ce/bin/x86_arm/cl.exe")
> SET(CMAKE_CXX_COMPILER "/Programme/Microsoft Visual Studio
> 8/VC/ce/bin/x86_arm/cl.exe")
> # here is the target environment located
> SET(CMAKE_FIND_ROOT_PATH  "/Programme/Microsoft Visual Studio 8/VC/ce")

You should use the full path including the drive letter, i.e. 
c:/Programme/.....

> # adjust the default behaviour of the FIND_XXX() commands:
> # search headers and libraries in the target environment, search
> # programs in the host environment
> set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
> set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
> set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
>
> ... and the platform file WindowsMobile.cmake located in config\Platform
> is at the end of the mail. I have removed some checks there, and am not
> sure if all is ok there.

I suggest you remove everything except the stuff you need right now. This will 
make it easier to understand and debug.

> Now cmake fails after scanning the WindowsMobile.cmake with a message
> which is not telling me much:
>
> -- Check for working C compiler: /Programme/Microsoft Visual Studio
> 8/VC/ce/bin/x86_arm/cl.exe
> CMake Error: Invalid escape sequence \w
> Syntax error in cmake code at
> C:/work/sw-repo/trunk/osal/build-arm-wince-nmake/Debug/CMakeFiles/CMakeTmp/
>CMakeLists.txt:1: syntax error, unexpected cal_ERROR, expecting $end (4),
> when parsing string
> "C:\work\sw-repo\trunk\osal\build-arm-wince-nmake\Debug\..\..\..\config\cma
>ke" CMake Error: Internal CMake error, TryCompile configure of cmake failed
>
> etc.
> Any ideas how to make it through ?


It seems to get the string "C:
\work\sw-repo\trunk\osal\build-arm-wince-nmake\Debug\..\..\..\config\cmake" 
as a path for a file or directory. Inside cmake all paths should have forward 
slashes, i.e. c:/work/sw-repo/.....".

You can run cmake ..... --debug-trycompile, then cmake will not remove the 
directory it created for its trycompile runs, so you can have a look at the 
created files. You should use this really only for debugging, since the files 
which have not been removed may have unwanted effects on later try-compiles.


Bye
Alex


More information about the CMake mailing list