Run a CMake-generated INSTALL.vcxproj on Windows via command line only?

匆匆过客 提交于 2020-06-24 10:25:13

问题


I have a C++ program that I'm trying to build and deploy on AppVeyor (thus, I have no GUI tools available). The dependencies of my project each use CMake for their build systems, and CMake (by default) generates Visual Studio project files on Windows.

One of the generated project files is named INSTALL.vcxproj, which presumably installs the dependency somewhere more or less standard. How can I execute the build process of INSTALL.vcxproj using only the command line?

Note: I am not married to Visual Studio project files. If it's more convenient to just use another generator, that's fine too (if you can explain to me how).


回答1:


To invoke the building of a specific target, use the --target option of cmake --build, i.e. in your case the command will look like cmake --build (YOUR_BUILD_FOLDER) --config Release --target install. Of course you need to set up your compiler environment using vcvarsall.bat. You can use this command with other generators as well (note, that --config option is for multi-configuration tools only, MSVS is one of them).




回答2:


cmake on windows (with Visual studio) will generate severial files:

  1. 1.sln
  2. a.vcxproj
  3. b.vcxproj
  4. INSTALL.vxcproj

To build, just open the Visual Studio Command Prompt and run:

msbuild b.vcxproj

If a.vcxproj is reference by b, it will be built automatically.

To install, open Visual Studio Command Prompt as administrator, and run:

msbuild INSTALL.vcxproj

These are equivalent to linux:

make
make install


来源:https://stackoverflow.com/questions/33291856/run-a-cmake-generated-install-vcxproj-on-windows-via-command-line-only

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