Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MinGW trying to use cmd.exe from CMake Makefiles

I'm trying to build cuneiform under Windows. I use CMake to generate the build and select the MinGW Makefiles option.

Internally the Makefiles have DOS C:\pathname style paths rather than unix style and SHELL is set to cmd.exe (I note that MinGW's bin dir has a cmd script but no cmd.exe) rather than bash or sh.

I start bash by double clicking on C:\MinGWzmsys\1.0\bin\bash.exe. When I then try to run make it says:

bash.exe"-3.1$ cd /c/cuneiform/build/
bash.exe"-3.1$ make
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
c:\cuneiform\build>

I then have to type exit three times to get back into bash! Why?

I've tried to generate Makefiles that use unix style paths and call sh but can't get CMake to do that for some reason.

Ideally should I be trying this from within bash or DOS? If I try from DOS (after setting a minimal path to path=C:\MinGW\msys\1.0\bin;C:\Windows\System32) make dies in a similar fashion.

I normally write C++ under HP-UX or Java under Windows, so MinGW and CMake are all new to me, as I'm sure you can tell.

like image 805
UnixNerd Avatar asked Nov 26 '13 18:11

UnixNerd


2 Answers

According to cmake doc, on Windows, MinGW Makefiles should be used when the shell is cmd.exe and MSYS Makefiles when the shell is sh.exe.

Trying cmake -G "MinGW Makefiles" when inside a bash shell will give you an error, so you should be consistent with your environment. If you don't need unix tools to build your project (grep, sed, etc), you really don't need to run bash then.

In my experiences, I've found that TDM GCC suite works better if you are not interested in the Unix environment and tools and need only the compiler.

like image 125
Leonardo Avatar answered Oct 23 '22 00:10

Leonardo


Converting my comment into answer as requested. Since different CMake generators produce different (e.g. syntax-wise) native build systems, in your case, there are basically two options:

  1. cmake ... -G "MSYS Makefiles" ... && make (e.g. when using MSYS2)
  2. cmake ... -G "MinGW Makefiles" ... && mingw32-make
like image 1
Alexander Shukaev Avatar answered Oct 23 '22 00:10

Alexander Shukaev