简体   繁体   中英

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.

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM