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

I am currently devoloping the Python 2.7 interface using SWIG for a C ++ project configured by CMAKE (not developed by myself, I just started CMAKE for this project). The project compiles (and works) perfectly under VS2010, using FIND_PACKAGE for python and swig. However, python 2.7 (and other versions) compiles using the VS2008 compiler, which is not binary compatible with VS2010. I installed the Windows SDK 7 compiler and I can compile another SWIG project (without CMAKE) using distutils. Trying to set up a real project using CMAKE for Visual Studio 2008 failed:

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 and in the regular shell.

Has anyone successfully configured the CMAKE project for the Windows SDK 7 compiler when another version of VS is installed? If so, how? Finally, I would rather use the python distutils configuration configured by CMAKE than build the project using the generated .sln file. Therefore, creating VS2008.sln / .prj does not matter.

+6
source share
1 answer

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

Then just run CMake and let it generate NMake make files:

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

This should guarantee the use of your compiler.

If this does not work, the SDK (or VS) must come with the tool to make the SDK version of the specific version.

+4
source

Source: https://habr.com/ru/post/958842/


All Articles