0

I have a similar query and close it as I thought it worked. Actually I still have problem. So I post in a new thread. My CMake is always building for Visual Studio 2010. I am cross compiling for Raspberry PI and my toolchain file is as follow.

SET(CMAKE_SYSTEM_NAME Linux) # this one is important
SET(CMAKE_SYSTEM_VERSION 1)  # this one not so much

SET(CMAKE_C_COMPILER   C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++)
SET(CMAKE_AR           C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-ar)
SET(CMAKE_LINKER       C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-ld)
SET(CMAKE_NM           C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-nm)
SET(CMAKE_OBJCOPY      C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-objcopy)
SET(CMAKE_OBJDUMP      C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-objdump)
SET(CMAKE_STRIP       C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-strip)
SET(CMAKE_RANLIB       C:/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-tanlib)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH  C:/ThitSan_Backup/RasberryPI/rpi/helloWorld)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

But when I run cmake, it build for Visual Studio 2010 as shown in the attached image.enter image description here Both cmake -D CMAKE_TOOLCHAIN_FILE=../toolchain-rpi.cmake ../ and cmake CMAKE_TOOLCHAIN_FILE=../toolchain-rpi.cmake ../gave me same results. My question are
(1) why cmake is trying to build for Visual Studio 2010 in default?
(2)What are the things I need to look at to cross compile for Raspberry PI using arm compiler to avoid such problem? Thanks

Community
  • 1
  • 1
batuman
  • 7,066
  • 26
  • 107
  • 229
  • Try removing the space after the `-D` (see [this answer](http://stackoverflow.com/a/17181954/2556117) for further info). – Fraser May 27 '14 at 20:01
  • I think, still the same. Let me try tonight. – batuman May 28 '14 at 02:15
  • I am sorry the initial question http://stackoverflow.com/questions/23856544/makefile-generator-specification-at-cross-compilation-with-cmake was not satisfactory. You could have unaccepted my answer, and edit your question to make it more precise. That would have been perfectly fine. – lrineau May 28 '14 at 08:41
  • @lrineau Many thanks. I edited my query to be more specific for what I like to know. – batuman May 28 '14 at 09:24
  • @lrineau I am in Windows 7 OS and I set the environment Path to C:\arm-bcm2708\gcc-linaro-arm-linux-gnueabihf-raspbian\bin. But when I test it at command window as arm-linux-gnueabihf-gcc -v. It is complained as "arm-linux-gnueabihf-gcc" is not recognized. I think this is the problem. – batuman May 28 '14 at 14:22
  • Once you have the solution, I suggest you write an official "answer" post, and then self-accept it. – lrineau May 28 '14 at 14:24
  • I set to the path for the bin folder, don't know why "arm-linux-gnueabihf-gcc" is not recognized. – batuman May 28 '14 at 14:44
  • According to this discussion (http://www.raspberrypi.org/forums/viewtopic.php?f=7&t=4058), there is no way to cross compile from Windows for Raspberry PI.That is the solution. I have to find Linux OS. Actually there is a way, but not straight forward. – batuman May 28 '14 at 14:54
  • That is why Cmake is always building for Visual Studio 10. – batuman May 28 '14 at 15:00

2 Answers2

1

I followed all the instructions and discussions in this link. But Arm Cross Compiler for the RPI is just for the Linux OS. So my solution for that is I installed Oracle's VirtualBox. Then implement all cross-compile in that OS.

batuman
  • 7,066
  • 26
  • 107
  • 229
1

I have been able to run cmake on windows without generating Visual Studio project. The solution is to install MinGW on Windows, and then use the following command to generate Makefiles:

cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=../toolchain-rpi.cmake ..

Finally, file named Makefile is generated instead of Visual Studio project. Please be sure there is no other sh.exe in your PATH env variable.

kenny-liu
  • 309
  • 2
  • 8