Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use CMAKE for Windows-SDK compiler, when VS2010 is installed?

I am currently devoloping a Python 2.7 frontend using SWIG for a C++ project configured by CMAKE (not developed by myself, I just started CMAKE for this project). The project compiles (and runs) fine under VS2010 using FIND_PACKAGE for python and swig. However, python 2.7 (and other releases) is compiled using the VS2008 compiler, which is not binary compatible with VS2010. I have installed the Windows SDK 7 compiler, and I can compile another SWIG project (without CMAKE) using distutils. Trying to configure the actual project with CMAKE for Visual Studio 2008, fails with:

xxx> cmake . -G "Visual Studio 9 2008"
CMake Error: CMake was unable to find a build program corresponding to "Visual Studio 9 2008".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.          
CMake Error: Could not find cmake module file: xxx/CMakeFiles/2.8.12/CMakeCXXCompiler.cmake                                                    
CMake Error: Could not find cmake module file: xxx/CMakeFiles/2.8.12/CMakeCCompiler.cmake    

(I replaced my actual path with xxx)

This happens both in the Windows-SDK shell, as well as in a normal shell.

Has anybody configured a CMAKE project successfully for Windows SDK 7 compiler, when another VS version is installed? If yes, how? Finally I would rather use a CMAKE configured python distutils build, than build the project using a generated .sln file. Hence, creating a VS2008 .sln / .prj is not important.

like image 444
oekopez Avatar asked Nov 26 '13 09:11

oekopez


People also ask

Where is MSVC compiler installed?

More precisely, the default path where you'll find the compiler is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin .

How to configure CMake for Visual Studio?

Building CMake projects Select the preferred configuration and press F5, or choose the Run (green triangle) button on the toolbar. The project automatically builds first, just like a Visual Studio solution. Right-click on CMakeLists. txt in Solution Explorer and select Build from the context menu.

Where is the C++ compiler in Visual Studio?

C++ compiler and linker options are located under the C/C++ and Linker nodes in the left pane under Configuration Properties. These options translate directly to command-line options that will be passed to the compiler. To read documentation about a specific option, select the option in the center pane and press F1.


1 Answers

I would just open the SDK command prompt, so the cl.exe you want (in the VS 2008 install directory) is in PATH (you can check this is the case with where cl).

Then just run CMake and let it generate NMake makefiles:

mkdir build && cd build
cmake .. -G "NMake Makefiles"

This should ensure your compiler of choice is used.

If this doesn't work either, the SDK (or VS) should come with a tool to make a certain SDK version "current".

like image 63
rubenvb Avatar answered Oct 15 '22 09:10

rubenvb