[CMake] Where to declare the CMAKE_C_FLAGS for cross compiling
Martin Kupke
martin.kupke at novero.com
Mon Sep 19 12:04:17 EDT 2011
I'm using a toolchain file with the CMAKE_SYSTEM_NAME "Generic", because
I want to cross compile on a Windows XP machine for a PPC (PowerPC)
processor. From my point of view it should be in a way as in the
documentation for the SDCC.
My toolchain file "toolchain_ppc.cmake" is setup:
#############################################
set(CMAKE_SYSTEM_NAME "Generic")
if(CMAKE_CROSSCOMPILING)
message("Cross Compiling")
endif(CMAKE_CROSSCOMPILING)
# which compilers to use for C and C++
set(CMAKE_C_COMPILER "dcc.exe")
set(CMAKE_FIND_ROOT_PATH "C:/WindRiver/diab/5.9.0.0/WIN32/bin")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_FLAGS "-tPPCVLEEN:simple")
#############################################
Additionally in the Platform folder I created a Generic-dcc file for
system specific options:
#############################################
MESSAGE("SYSTEM_NAME=Generic")
set(CMAKE_C_FLAGS "-tPPCVLEEN:simple")
#############################################
In the windows console I call the CMake tool in an empty output folder:
D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -G "NMake
Makefiles" -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" ..
The output of the CMake process shows that the test compilation could
not be performed and the reason for that is, that my CMAKE_C_FLAGS are
not passed to the configured compiler dcc.exe.
#############################################
Cross Compiling
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
SYSTEM_NAME=Generic
-- Check for working C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe
-- 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/CMakeTestCCompiler.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/CMakeTmp
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\CMakeFiles
1
Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj
(LOOK_HERE)-> 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\testCCompiler.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)
CMake Error: your CXX compiler: "cl" was not found. Please set
CMAKE_CXX_COMPILER to a valid compiler path or name.
-- Configuring incomplete, errors occurred!
#############################################
I marked the position in the output with (LOOK_HERE)-> where you can see
that the necessary compile flags CMAKE_C_FLAGS "-tPPCVLEEN:simple" have
not been passed to the compiler. Where do I have to declare the
CMAKE_C_FLAGS?
More information about the CMake
mailing list