Quantcast

Where to declare the CMAKE_C_FLAGS for cross compiling

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Where to declare the CMAKE_C_FLAGS for cross compiling

Martin Kupke
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?


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Where to declare the CMAKE_C_FLAGS for cross compiling

Martin Kupke
For cross compiling I need to set the variables "CMAKE_C_FLAGS_INIT" and "CMAKE_CXX_FLAGS_INIT" in the Platform Generic-dcc file.
Not sure why I need to configure CXX compiler and flags, even I don't use them...but that's another story.

Now the CMake tool passes and finished without any errors, but the created Makefile for "NMake Makefiles" Generator can't compile my source file.
################### output of NMake ###################
D:\novero\Discovery\impl\target\CarIF_Appl\output>nmake

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
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.
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2'
Stop.
################### output of NMake ###################

I assume that there is a problem with blanks in the path name, because of the output "'C:\Program' is not recognized as an internal or external command,". I guess it would be something like "C:\Program Files\...." and the blank / space character confuses the build process.

Any ideas to blanks / spaces in files and foldernames?

Thanks
Martin...

On 19.09.11 18:04, Martin Kupke wrote:
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?


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

--


martin kupke

can diagnostics engineer | senior software developer

m: +49.151.5511.3632 | e: [hidden email]

skype:  martin.kupke_novero  | w: www.novero.com

novero GmbH
meesmannstr.103 | 44807 Bochum | germany


novero gmbh | parsevalstr.
7 a | 40468 düsseldorf | germany | amtsgericht düsseldorf | hrb 58283 | umsatzsteueridentifikationsnummer: de 814973142 | geschäftsführender gesellschafter: razvan olosu

 


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Loading...