[CMake] Cross compiling in Win32 environment doesn't work

Martin Kupke martin.kupke at novero.com
Mon Sep 19 08:44:43 EDT 2011


I'm using CMake in version 2.8.5 and just want to cross compile with a 
decicated Compiler / Linker set on my Windows machine. Of course I've 
read the FAQ and the Tutorial, afterwards I started trying to use CMake 
on a DOS (cmd.exe) command line interface with CMakeLists.txt and a 
toolchain file. After all tests failed to get CMake work in the Win32 
environment, I tried it in my private Linux (Debian Squeeze) and the 
same procedure is successful. In Linux environment it works as 
described, in Win32 not.

My PC has installed Windows XP including SP3.
CMake version 2.8.5 is installed.
My development path contains a CMakeLists.txt and a toolchain_ppc.cmake 
file, because I want to compile on my WinXP code for an embedded 
hardware using a PPC processor.
The toolchain_ppc.cmake file contains the following settings:
set (CMAKE_GENERATOR "NMake Makefiles")
set (CMAKE_SYSTEM_NAME "Generic")
set (CMAKE_C_COMPILER "dcc.exe")
set (CMAKE_SYSTEM_PROCESSOR "ppc")

if(CMAKE_CROSSCOMPILING)
message("Cross Compiling")
endif(CMAKE_CROSSCOMPILING)

set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe")
set(CMAKE_C_FLAGS "-tPPCVLEEN:simple")

In my build environment I created an empty folder output and in the 
command line interface (console / cmd.exe) I'm calling the cmake tool:
D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -D 
CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" ..
The output of the cmake tool always is:
-- Building for: Visual Studio 10
Cross Compiling

As you can see my message "Cross Compiling" is shown, this introduces 
that cmake is using the "CMAKE_CROSSCOMPILING" flag. But why the hell is 
there always the output "-- Building for: Visual Studio 10"?
I don't wan't to use anything from / for Visual Studio 10.

The CMakeOutput.log contains the following lines:
The target system is: Generic -  - ppc
The host system is: Windows - 5.1 - x86
Compiling the C compiler identification source file "CMakeCCompilerId.c" 
succeeded.
Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe
Build flags: -tPPCVLEEN:simple
Id flags:

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" 
produced "a.out"

Compiling the C compiler identification source file "CMakeCCompilerId.c" 
succeeded.
Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe
Build flags: -tPPCVLEEN:simple
Id flags: -c

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" 
produced "CMakeCCompilerId.o"

Compiling the CXX compiler identification source file 
"CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe
Build flags: -tPPCVLEEN:simple
Id flags:

The output was:
0


Compilation of the CXX compiler identification source 
"CMakeCXXCompilerId.cpp" produced "a.out"

Compiling the CXX compiler identification source file 
"CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe
Build flags: -tPPCVLEEN:simple
Id flags: -c

The output was:
0


Compilation of the CXX compiler identification source 
"CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o"

Determining if the C compiler works passed with the following output:
Change Dir: 
D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp

Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com 
CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec


Microsoft (R) Visual Studio Version 10.0.30319.1.

Copyright (C) Microsoft Corp. All rights reserved.

1>------ Build started: Project: cmTryCompileExec, Configuration: Debug 
Win32 ------

1>  testCCompiler.c

1>C:\Program 
Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): 
warning MSB8012: 
TargetPath(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec) 
does not match the Linker's OutputFile property value 
(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec.exe). 
This may cause your project to build incorrectly. To correct this, 
please make sure that $(OutDir), $(TargetName) and $(TargetExt) property 
values match the value specified in %(Link.OutputFile).

1>  cmTryCompileExec.vcxproj -> 
D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========



Detecting C compiler ABI info compiled with the following output:
Change Dir: 
D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp

Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com 
CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec


Microsoft (R) Visual Studio Version 10.0.30319.1.

Copyright (C) Microsoft Corp. All rights reserved.

1>------ Build started: Project: cmTryCompileExec, Configuration: Debug 
Win32 ------

1>  CMakeCCompilerABI.c

1>C:\Program 
Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): 
warning MSB8012: 
TargetPath(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec) 
does not match the Linker's OutputFile property value 
(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec.exe). 
This may cause your project to build incorrectly. To correct this, 
please make sure that $(OutDir), $(TargetName) and $(TargetExt) property 
values match the value specified in %(Link.OutputFile).

1>  cmTryCompileExec.vcxproj -> 
D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========



Determining if the CXX compiler works passed with the following output:
Change Dir: 
D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp

Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com 
CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec


Microsoft (R) Visual Studio Version 10.0.30319.1.

Copyright (C) Microsoft Corp. All rights reserved.

1>------ Build started: Project: cmTryCompileExec, Configuration: Debug 
Win32 ------

1>  testCXXCompiler.cxx

1>C:\Program 
Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): 
warning MSB8012: 
TargetPath(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec) 
does not match the Linker's OutputFile property value 
(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec.exe). 
This may cause your project to build incorrectly. To correct this, 
please make sure that $(OutDir), $(TargetName) and $(TargetExt) property 
values match the value specified in %(Link.OutputFile).

1>  cmTryCompileExec.vcxproj -> 
D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========



Detecting CXX compiler ABI info compiled with the following output:
Change Dir: 
D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp

Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com 
CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec


Microsoft (R) Visual Studio Version 10.0.30319.1.

Copyright (C) Microsoft Corp. All rights reserved.

1>------ Build started: Project: cmTryCompileExec, Configuration: Debug 
Win32 ------

1>  CMakeCXXCompilerABI.cpp

1>C:\Program 
Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): 
warning MSB8012: 
TargetPath(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec) 
does not match the Linker's OutputFile property value 
(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec.exe). 
This may cause your project to build incorrectly. To correct this, 
please make sure that $(OutDir), $(TargetName) and $(TargetExt) property 
values match the value specified in %(Link.OutputFile).

1>  cmTryCompileExec.vcxproj -> 
D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


I just want to use a standard Assembler, C Compiler and Linker.
I don't need CXX (C++) in my build environment and even I don't need 
(want) any Visual Studio in my Cross Compilation.
The generator for CMake shall be "NMake Makefiles" so that the generated 
Makefile can be used with "NMake".

Hopefully you can help me out of this.




More information about the CMake mailing list