CMake version 2.8.9
I am writing an app for Windows 8 to run on tablets. I have written an underlying C++ library that contains the majority of my application logic. I am using CMake to compile this C++ library because I want to have a platform-independent build system for future ports.
When I run cmake.exe from the command line or use cmake-gui, I can generate projects using the “Visual Studio 11” and “Visual Studio 11 Win64” generators. However, when I try to use the “Visual Studio 11 ARM” generator I get the following error:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "cl" is not able to compile a simple test program.
The cause is in the more detailed output:
1>------ Build started: Project: cmTryCompileExec2764216458, Configuration: Debug ARM ------
1>C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\ARM\PlatformToolsets\v110\Microsoft.Cpp.ARM.v110.targets(36,5):
error MSB8022: Compiling Desktop applications for the ARM platform is not supported.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It appears that by default the “Visual Studio 11 ARM” generator doesn’t work because cl.exe will not allow CMake to test the compiler.
I’ve read that I can turn off compiler checks altogether but that sounds like a poor choice. Is this just a bug in CMake?
Sorry, I should have posted the workaround I used.
Instead of using the ‘Visual Studio 11 ARM’ generator, I switched to NMake and was able to get it working. The guys over at CMake will probably fix the Visual Studio generator in their 2.8.11 release.
The trick to using NMake to build for ARM is just to run the batch script that sets up your environment to cross-compile before invoking cmake. Or, you could also just open “VS2012 ARM Cross Tools Command Prompt”. The batch script is located at:
The command line I used for cmake was:
You can substitute “Release” for “Debug” of course. I think everyone should do out of source builds, but you can run the command in the same directory as your CMakeLists.txt and omit the last parameter.
In order to build successfully, you will need to set the following in your CMakeLists.txt:
If you are building for multiple platforms, a good way that I found to detect that I was building for ARM to set the above variables was to check the environment:
I don’t think this last part is necessary, but I noticed that there are a lot of standard libraries missing in the ARM SDK, so I setup the libraries to exclude everything that is unavailable by setting the following:
When you’re all finished, just run:
Anyway, this worked for me. I don’t think I had to do anything else to get it working for my particular project. Good luck!