Using CMake with Windows 7, Visual Studio 2010, and the command line

╄→гoц情女王★ 提交于 2019-12-21 09:13:33

问题


How do I use CMake with Visual Studio 2010 on the command line?

With Visual C++ Express Edition (2010) I would type:

cmake .
nmake
nmake install

simple.

I noticed with Visual Studio 2010, CMake generates a solution file instead of a Makefile. So I type:

cmake .
msbuild mysolutionfile.sln

But then what? I used to be able to type "nmake install" and it would install the project. What do I type now to install the project?


回答1:


Two points:

1- CMake: You can choose your generator. Visual Studio happens to be the default in your case. If you want to use nmake, you can add the following to your cmake command: -G "NMake Makefiles". Alternatively, you can use cmake-gui.exe and the first option will be to choose your generator in a drop-down list. Make sure to remove your previously generated build dir and cmakecache.

2- Visual Studio: you can specify the target to msbuild with /target:INSTALL. Typically cmake creates an INSTALL project: building this project mimicks running make install.

Cheers.




回答2:


devenv mysolutionfile.sln /build Debug /project INSTALL

This is preferable to using msbuild or vcbuild because certain versions of Visual Studio seem to have trouble with the inter-project dependencies that cmake likes to generate.

And devenv is preferable to nmake because it gives you more control over debug configurations, etc.



来源:https://stackoverflow.com/questions/4219479/using-cmake-with-windows-7-visual-studio-2010-and-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!