无法在Windows上使用MinGW和git bash运行Cmake

6
我会尝试构建gitql
我已经安装了go、CMake和MinGW,并尝试在git bash下使它们工作,但是当我在gitql目录中调用cmake时,我会收到以下错误:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:14 (PROJECT):
  The CMAKE_C_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  To use the NMake generator with Visual C++, cmake must be run from a shell
  that can use the compiler cl from the command line.  This environment is
  unable to invoke the cl compiler.  To fix this problem, run cmake from the
  Visual Studio Command Prompt (vcvarsall.bat).

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeOutput.log".
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeError.log".
make: *** [prepare] B▒▒d 1

所以我尝试使用以下方式从mingw指向gcc:

export CC=/c/MinGW/bin/gcc.exe

当我运行make时,出现以下错误:

-- Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_14ff0\fast"
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeTmp



  Run Build Command:"nmake" "/NOLOGO" "cmTC_14ff0\fast"



  Generator: execution of make failed.  Make command was: "nmake" "/NOLOGO"
  "cmTC_14ff0\fast"





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:14 (PROJECT)


-- Configuring incomplete, errors occurred!
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeOutput.log".
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeError.log".
make: *** [prepare] B▒▒d 1

我该如何告诉cmake使用make而不是nmake?我已经在$PATH中安装了位于C:\Program Files (x86)\GnuWin32\bin的make。

我还尝试调用cmake -G "MinGW Makefiles",但是出现了以下错误:

CMake Error: The source directory "C:/Go/src/github.com/cloudson/gitql" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

顺便说一下:使用ninja比make更高效,并且它得到了cmake的良好支持。它的设置非常简单(只需将一个可执行文件添加到您的路径中),因此我真的建议您尝试一下。请参见https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html。确保在cmake文件的某个地方定义:`SET(CMAKE_COMPILER_IS_MINGW true CACHE BOOL "Workaround to allow correct path interpretation")`。 - Antonio
1个回答

3

cmake -G "MinGW Makefiles" 是告诉 CMake 你想使用 MinGW 的正确命令。

为了完整起见,你应该创建一个单独的文件夹,我们称之为 build,并从中调用 cmake 进行源外构建:

cd /path/to/build
cmake -G "MinGW Makefiles" /path/to/CMakeLists.txt

这里的问题是gitql代码库中没有提供CMakeLists.txt文件,因此你无法使用CMake进行构建,除非你自己创建项目文件。你可以尝试使用提供的Makefile,并将其作为pull请求提交。

这不是一份公关,而是为了达成公关所做的一些工作。等待维护者出现并给予反馈 - https://github.com/cloudson/gitql/issues/42#issuecomment-462407339 - budden73

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接