[CMake] cmake 2.5 with windows mobile
Artur Wisz
wisz at bury.com
Sat Sep 1 06:16:52 EDT 2007
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.
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
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.cmake
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%CD%\..\..\..\arm-wince
-DTARGET_PLATFORM=arm-wince -G "NMake Makefiles" ..\..
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")
# 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.
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\cmake"
CMake Error: Internal CMake error, TryCompile configure of cmake failed
etc.
Any ideas how to make it through ?
Thanks,
Art
MESSAGE(STATUS "Took WindowsMobile.cmake")
SET(WIN32 1)
INCLUDE(Platform/cl)
SET(CMAKE_CREATE_WIN32_EXE /subsystem:windowsce,5.01)
SET(CMAKE_CREATE_CONSOLE_EXE /subsystem:console)
IF(CMAKE_GENERATOR MATCHES "Visual Studio 6")
SET (CMAKE_NO_BUILD_TYPE 1)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 6")
IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8")
SET (CMAKE_NO_BUILD_TYPE 1)
SET (CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo" CACHE STRING
"Semicolon separated list of supported configuration types, only supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.")
MARK_AS_ADVANCED(CMAKE_CONFIGURATION_TYPES)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8")
# does the compiler support pdbtype and is it the newer compiler
IF(CMAKE_GENERATOR MATCHES "Visual Studio 8")
SET(CMAKE_COMPILER_2005 1)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8")
MESSAGE(STATUS "Checkpoint 1")
#ENABLE_LANGUAGE(RC)
#SET(CMAKE_COMPILE_RESOURCE "rc <FLAGS> /fo<OBJECT> <SOURCE>")
MESSAGE(STATUS "Checkpoint 11")
# for nmake we need to compute some information about the compiler
# that is being used.
# the compiler may be free command line, 6, 7, or 71, and
# each have properties that must be determined.
# to avoid running these tests with each cmake run, the
# test results are saved in CMakeCPlatform.cmake, a file
# that is automatically copied into try_compile directories
# by the global generator.
SET(MSVC_IDE 1)
IF(CMAKE_GENERATOR MATCHES "Makefiles")
SET(MSVC_IDE 0)
IF(NOT CMAKE_VC_COMPILER_TESTS_RUN)
SET(CMAKE_VC_COMPILER_TESTS 1)
SET(testNmakeCLVersionFile
"${CMAKE_ROOT}/Modules/CMakeTestNMakeCLVersion.c")
STRING(REGEX REPLACE "/" "\\\\" testNmakeCLVersionFile "${testNmakeCLVersionFile}")
MESSAGE(STATUS "Check for CL compiler version")
SET(CMAKE_TEST_COMPILER ${CMAKE_C_COMPILER})
IF (NOT CMAKE_C_COMPILER)
SET(CMAKE_TEST_COMPILER ${CMAKE_CXX_COMPILER})
ENDIF(NOT CMAKE_C_COMPILER)
MESSAGE(STATUS Checkpoint 2)
EXEC_PROGRAM(${CMAKE_TEST_COMPILER}
ARGS /nologo /EP \"${testNmakeCLVersionFile}\"
OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT
RETURN_VALUE CMAKE_COMPILER_RETURN
)
IF(NOT CMAKE_COMPILER_RETURN)
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining the version of compiler passed with the following output:\n"
"${CMAKE_COMPILER_OUTPUT}\n\n")
STRING(REGEX REPLACE "\n" " " compilerVersion "${CMAKE_COMPILER_OUTPUT}")
STRING(REPLACE "CloseHandleError" "" compilerVersion "${compilerVersion}")
STRING(REGEX REPLACE ".*VERSION=(.*)" "\\1" compilerVersion "${compilerVersion}")
MESSAGE(STATUS "Check for CL compiler version - ${compilerVersion}")
SET(MSVC60)
SET(MSVC70)
SET(MSVC71)
SET(MSVC80)
SET(CMAKE_COMPILER_2005)
IF("${compilerVersion}" LESS 1300)
SET(MSVC60 1)
SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1)
ENDIF("${compilerVersion}" LESS 1300)
IF("${compilerVersion}" EQUAL 1300)
SET(MSVC70 1)
SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0)
ENDIF("${compilerVersion}" EQUAL 1300)
IF("${compilerVersion}" EQUAL 1310)
SET(MSVC71 1)
SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0)
ENDIF("${compilerVersion}" EQUAL 1310)
IF("${compilerVersion}" EQUAL 1400)
SET(MSVC80 1)
SET(CMAKE_COMPILER_2005 1)
ENDIF("${compilerVersion}" EQUAL 1400)
IF("${compilerVersion}" GREATER 1400)
SET(MSVC80 1)
SET(CMAKE_COMPILER_2005 1)
ENDIF("${compilerVersion}" GREATER 1400)
SET(MSVC_VERSION "${compilerVersion}")
ELSE(NOT CMAKE_COMPILER_RETURN)
MESSAGE(STATUS "Check for CL compiler version - failed")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining the version of compiler failed with the following output:\n"
"${CMAKE_COMPILER_OUTPUT}\n\n")
ENDIF(NOT CMAKE_COMPILER_RETURN)
MESSAGE(STATUS Checkpoint 3)
# try to figure out if we are running the free command line
# tools from Microsoft. These tools do not provide debug libraries,
# so the link flags used have to be different.
MAKE_DIRECTORY("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp2")
SET(testForFreeVCFile
"${CMAKE_ROOT}/Modules/CMakeTestForFreeVC.cxx")
STRING(REGEX REPLACE "/" "\\\\" testForFreeVCFile "${testForFreeVCFile}")
SET(CMAKE_USING_VC_FREE_TOOLS 0)
SET(CMAKE_CL_64 0)
ENDIF(NOT CMAKE_VC_COMPILER_TESTS_RUN)
ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")
MESSAGE(STATUS Checkpoint 4)
# Not used by generator directly but referenced below.
SET(CMAKE_CREATE_LIB_MANIFEST
"$(CMAKE_COMMAND) -DTARGET=<TARGET> -DCMAKE_CL_NOLOGO=${CMAKE_CL_NOLOGO} -P \"${CMAKE_ROOT}/Modules/CMakeVCManifest.cmake\"")
SET(CMAKE_CREATE_EXE_MANIFEST
"$(CMAKE_COMMAND) -DTARGET=<TARGET> -DCMAKE_CL_NOLOGO=${CMAKE_CL_NOLOGO} -P \"${CMAKE_ROOT}/Modules/CMakeVCManifestExe.cmake\"")
# for 2005 make sure the manifest is put in the dll with mt
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}"
${CMAKE_CREATE_LIB_MANIFEST})
SET(CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}"
${CMAKE_CREATE_LIB_MANIFEST})
# create a C shared library
SET(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
# create a C shared module just copy the shared library rule
SET(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}"
${CMAKE_CREATE_EXE_MANIFEST})
SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}"
${CMAKE_CREATE_EXE_MANIFEST})
SET(CMAKE_BUILD_TYPE_INIT Debug)
SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /D_WIN32_WCE=0x501 /D UNDER_CE /D WIN32_PLATFORM_PSPC /D WINCE /D ARM /D _ARM_ /D _UNICODE /D UNICODE /fp:fast /W3 /Zm1000 /EHsc /GR")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od")
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
SET (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /D_WIN32_WCE=0x501 /D UNDER_CE /D WIN32_PLATFORM_PSPC /D WINCE /D ARM /D _ARM_ /D _UNICODE /D UNICODE /fp:fast /W3 /Zm1000")
SET (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
SET (CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib")
SET (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /MANIFEST")
MESSAGE(STATUS Checkpoint 5)
SET(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
# executable linker flags
SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:")
# set the stack size and the machine type
SET (CMAKE_EXE_LINKER_FLAGS_INIT
"${CMAKE_EXE_LINKER_FLAGS_INIT} /machine:THUMB")
# add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtyp
# on versions that support it
IF (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept /INCREMENTAL:YES")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept /INCREMENTAL:YES")
ELSE (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /INCREMENTAL:YES")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /INCREMENTAL:YES")
ENDIF (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
# for release and minsize release default to no incremental linking
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT "/INCREMENTAL:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "/INCREMENTAL:NO")
MESSAGE(STATUS Checkpoint 6)
# copy the EXE_LINKER flags to SHARED and MODULE linker flags
# shared linker flags
SET (CMAKE_SHARED_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT})
# module linker flags
SET (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT})
SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT})
SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT})
SET (CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT})
SET (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT})
# save computed information for this platform
IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake")
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCPlatform.cmake IMMEDIATE)
ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake")
IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake")
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXPlatform.cmake IMMEDIATE)
ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake")
MESSAGE(STATUS Checkpoint 7)
More information about the CMake
mailing list