Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run Cmake on windows with MinGW and git bash

I try to build gitql.

I've installed go, CMake and MinGW, and tried to make them work under git bash, but when I call cmake in gitql directory I get this error:

-- 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

So I've tried to point to gcc from mingw using:

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

and when I run make I get this error:

-- 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

How can I inform cmake to use make instead of nmake? I have make installed in C:\Program Files (x86)\GnuWin32\bin which is in $PATH.

I've also try to call cmake -G "MinGW Makefiles" but I've got this error:

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.
like image 908
jcubic Avatar asked Oct 17 '22 20:10

jcubic


1 Answers

cmake -G "MinGW Makefiles" is effectively the right command to inform CMake you want to use MinGW.

To be complete, you should create a separate folder, let's call it build, and call cmake from it to make an out-of-source build:

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

The problem here is gitql doesn't provide any CMakeLists.txt file in the repository, so you just can't use CMake to build it, unless you create your own project file. You can try from the given Makefile, and propose it as a pull request.

like image 157
rgmt Avatar answered Oct 30 '22 04:10

rgmt