CMake 不生成 MinGW makefile,而是生成 MSVS 2013

CMake does not generates MinGW makefile, but MSVS 2013

本文关键字:MSVS 2013 makefile MinGW CMake      更新时间:2023-10-16

我正在尝试从这里使用 MinGW 安装构建简单的控制台应用程序:http://nuwen.net/mingw.html。这个软件包已经包含GCC 4.9.2和Boost 1.57。创建这样的简单文件:

#include <iostream>
#include <boost/accumulators/accumulators.hpp>
using namespace std;
int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

之后,我执行以下操作:

> pwd
/d/..../Boost-Accumulators
> mkdir build
> cd build
> pwd
/d/..../Boost-Accumulators/build
> cmake -g "MinGW Makefiles" ..
-- Building for: Visual Studio 12 2013
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler using: Visual Studio 12 2013
-- Check for working C compiler using: Visual Studio 12 2013 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 12 2013
-- Check for working CXX compiler using: Visual Studio 12 2013 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/alp/Projects/Boost-Accumulators/build

毕竟,我只有MSVS项目/解决方案(我也有versio 2013安装)用于此应用程序构建。但我想使用 MinGW 安装构建它。

如何实现?

UPD: cmake -G "MinGW Makefiles" .. - 这是正确的命令行。我在执行它时发现了一个注释 - 我的 PATH 中有sh.exe - 一个在MSYS中,一个在Git目录中。它会影响 MinGW 构建,所以我重命名了它,所以两者都sh1.exe一切正常!

生成器选项为大写:-G

@Angew