[CMake] Cross compiling in Win32 environment doesn't work
Alexander Neundorf
a.neundorf-work at gmx.net
Mon Sep 19 23:29:56 EDT 2011
Hi,
can you please adjust your mail client so it doesn't send HTML mails ?
On Monday, September 19, 2011 04:57:32 PM Martin Kupke wrote:
> That's a hint, I changed my toolchain file "toolchain_ppc.cmake" to the
> following: INCLUDE(CMakeForceCompiler)
> set(CMAKE_SYSTEM_NAME "Discovery")
>
> if(CMAKE_CROSSCOMPILING)
> message("Cross Compiling")
> endif(CMAKE_CROSSCOMPILING)
>
> # which compilers to use for C and C++
> set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe")
> set(CMAKE_FORCE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe")
> set(CMAKE_C_FLAGS "-tPPCVLEEN:simple")
>
> Then I created a folder with the name Platform containing a file with
> CMAKE_SYSTEM_NAME which is Discovery -> at this point I had already
> problems, because CMake doesn't use as described the filename with .cmake
> extension. The filename in the Platform folder has to have the name from
> CMAKE_SYSTEM_NAME without the extension .cmake (even the documentation
> says something different). I checked this by adding the output of a
> message("SYSTEM_NAME=Discovery").
The filename must be Discovery.cmake in your case.
Did you say this didn't work ?
This file must be either in the cmake Modules/Platfom/ directory, or in a
subdirectory Platform/ of a directory which is in CMAKE_MODULE_PATH.
> The Platform/Discovery file contains the lines:
> message("SYSTEM_NAME=Discovery")
> set(CMAKE_FORCE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe")
> set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe")
> set(CMAKE_C_FLAGS "-tPPCVLEEN:simple")
> set(CMAKE_FORCE_C_FLAGS "-tPPCVLEEN:simple")
> set(CMAKE_FORCE_CXX_COMPILER
> "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_CXX_COMPILER
> "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_CXX_FLAGS
> "-tPPCVLEEN:simple")
> set(CMAKE_MAKE_PROGRAM "D:/novero/Discovery/impl/win32/nmake/nmake.exe")
That last line should not be necessary.
> Then I call from the command line the CMake tool with the parameters:
> D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -G "NMake
> Makefiles" -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" ..
>
> The following output will be produced:
> ********************* snip output *********************
> Cross Compiling
> -- The C compiler identification is unknown
> -- The CXX compiler identification is unknown
> SYSTEM_NAME=Discovery
> SYSTEM_NAME=Discovery
> -- Check for working C compiler:
> C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe System is unknown to cmake,
> create:
> Platform/Discovery to use this system, please send your config file to
> cmake at www .cmake.org so it can be added to cmake
> -- Check for working C compiler:
> C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe -- broken
> CMake Error at C:/Program Files/CMake
> 2.8/share/cmake-2.8/Modules/CMakeTestCComp iler.cmake:52 (MESSAGE):
> The C compiler "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe" is not able
> to compile a simple test program.
>
> It fails with the following output:
>
> Change Dir:
> D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMak eTmp
>
> Run Build Command:nmake /NOLOGO "cmTryCompileExec\fast"
>
> nmake -f CMakeFiles\cmTryCompileExec.dir\build.make /nologo -L
> CMakeFiles\cmTryCompileExec.dir\build
>
> "C:\Program Files\CMake 2.8\bin\cmake.exe" -E
> cmake_progress_report
> D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\CMak
> eFil es
> 1
>
> Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj
>
> C:\WindRiver\diab\5.9.0.0\WIN32\bin\dcc.exe -o
> CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj -c
>
> D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\test
> CCom piler.c
>
>
> Target Unknown. Use the -t option or set a default target with dctrl -t
>
> NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code
> '0x1'
>
> Stop.
>
> NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code
> '0x2'
>
> Stop.
>
> CMake will not be able to correctly generate this project.
> Call Stack (most recent call first):
> CMakeLists.txt:2 (project)
>
>
> -- Configuring incomplete, errors occurred!
> You have changed variables that require your cache to be deleted.
> Configure will be re-run and you may have to reset some variables.
> The following variables have changed:
> CMAKE_CXX_COMPILER= cl
>
> -- Generating done
> -- Build files have been written to:
> D:/novero/Discovery/impl/target/CarIF_Appl/ output
>
> ********************* snap output *********************
>
> 1.) with the output SYSTEM_NAME=Discovery I can see that the platform file
> is used 2.) the compilation doesn't complete, because the CMAKE_C_FLAGS
> are still not used
They are initialized later on.
There is a set of variables which are used for initialization, I think it's
name is CMAKE_C_FLAGS_INIT .
> 3.) why do I have to have a CXX (C++) compiler, even if
> I don't need it in my embedded solution
By default cmake enables C and C++.
If you put a
project(MyProject C)
into your toplevel CMakeLists.txt, only the C language will be enabled, not
C++.
> 4.) is there any reason why CMake
> needs to know my system? I want just to compile some files... (wondering)
Yes. It needs this information to be able to know e.g. search locations for
the find_xxx() calls, for file prefixes and suffixes, for knowing the compiler
flags for this compiler on this OS
Alex
More information about the CMake
mailing list