【问题标题】:Using CMake with Windows 7, Visual Studio 2010, and the command line在 Windows 7、Visual Studio 2010 和命令行中使用 CMake
【发布时间】:2011-05-12 07:02:31
【问题描述】:

如何在命令行上将 CMake 与 Visual Studio 2010 一起使用?

使用 Visual C++ Express Edition (2010) 我会输入:

cmake .
nmake
nmake install

简单。

我注意到在 Visual Studio 2010 中,CMake 会生成解决方案文件而不是 Makefile。所以我输入:

cmake .
msbuild mysolutionfile.sln

然后呢?我曾经能够输入“nmake install”,它会安装项目。我现在输入什么来安装项目?

【问题讨论】:

    标签: visual-studio-2010 windows-7 msbuild cmake nmake


    【解决方案1】:

    两点:

    1- CMake:您可以选择您的生成器。 Visual Studio 恰好是您的默认设置。如果你想使用 nmake,你可以在你的 cmake 命令中添加以下内容:-G "NMake Makefiles"。或者,您可以使用 cmake-gui.exe,第一个选项是在下拉列表中选择您的生成器。确保删除您之前生成的构建目录和 cmakecache。

    2- Visual Studio:您可以使用 /target:INSTALL 指定 msbuild 的目标。通常 cmake 会创建一个 INSTALL 项目:构建这个项目会模仿运行 make install。

    干杯。

    【讨论】:

      【解决方案2】:
      devenv mysolutionfile.sln /build Debug /project INSTALL
      

      这比使用msbuildvcbuild 更可取,因为某些版本的 Visual Studio 似乎在 cmake 喜欢生成的项目间依赖项方面存在问题。

      并且devenvnmake 更可取,因为它可以让您更好地控制调试配置等。

      【讨论】:

      • 但是 devenv 没有随 Visual Studio 的 Express 版本提供。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多