13

I have cmake 3.2.3 installed via pacman. I get an error when I try to use it from a msys64 shell:

$ cmake -G "MSYS Makefiles" ..
CMake Error: Could not create named generator MSYS Makefiles

cmake --help does not list it as an available generator.

I do see there is an MSYS.cmake in /usr/share/cmake-3.2.3/Modules/Platform.

What am I missing?

Scott Thibault
  • 269
  • 2
  • 3
  • 11

4 Answers4

21

Instead of installing the cmake package, I think you need to install mingw-w64-i686-cmake (or the 64-bit version mingw-w64-x86_64-cmake).

Evan
  • 1,802
  • 1
  • 15
  • 20
  • 1
    I also had to run `${MINGW_PREFIX}/bin/cmake` instead of just `cmake` to make it work. – Michaël Witrant Jan 05 '19 at 17:33
  • As of 2019, neither the 32-bit or 64-bit versions of mingw64 exist in the Cygwin installer and I can't find them via `apt-cyg`. – Hashim Aziz Mar 13 '19 at 03:24
  • @Hashim this question is about MinGW, not Cygwin. My understanding is that they are completely separate systems: https://stackoverflow.com/questions/771756/what-is-the-difference-between-cygwin-and-mingw – Evan Mar 13 '19 at 17:35
  • 1
    It's actually about MSYS Makefiles, which is the Cmake generator Cygwin relies on when using MinGW-64 packages to build (a common use case, as it's more reliable than building with the native Cygwin packages). My comment above doesn't change your answer, I just wanted to get it out in the open for those using Cygwin. – Hashim Aziz Mar 13 '19 at 18:30
3

I got the exact same message when trying to run cmake in the MSYS shell. Use a MinGW Shell (for instance MinGW-w64 Win64 Shell) instead.

Duane
  • 3,093
  • 2
  • 25
  • 26
  • Personally, I just add the MinGW bin directory to my path in my MSYS user's home dir via .bash_profile. This lets me use MSYS and specify which MinGW I want. I then use MSYS for just about everything terminal side. – Jimmio92 Aug 11 '20 at 01:31
2

If you compile native Windows binaries on Linux with MinGW

The MinGW and MSYS generators are only available on Windows based distributions. See #ifdef in cmake.cxx:

#if defined(_WIN32) && !defined(__CYGWIN__)

If you're cross-compiling use one of the available MinGW toolchains. See e.g. "How to use MinGW to cross compile software for Windows" chapter in CMake's wiki.

If you compile Windows binaries on Windows with MinGW

On my Windows PC I only have one CMake installation (the normal MSI Windows Installer with CMake directory added to PATH environment), which works from standard CMD shells and from my MSYS shells.

So in this case there is no need to install a special MinGW version of CMake (like e.g. for CygWin).

But I've rebuild CMake from source with MinGW-w64 several times lately to test some performance optimizations of cmake.exe and it did not work out-of-the-box. To work around the linker errors I've added -DCMAKE_EXE_LINKER_FLAGS="-Wl,--allow-multiple-definition" like recommended here and the resulting cmake.exe still supports the "MSYS Makefiles" generator.

So yes, there is - as you have commented - most probably something wrong with the pacman build.

Adam Baxter
  • 1,903
  • 19
  • 33
Florian
  • 31,784
  • 6
  • 98
  • 120
  • Well, it was built with msys/mingw so it is a windows distribution. Are you saying the generator list is hard-coded in the executable? I guess that would imply that there is something wrong with the pacman build. – Scott Thibault May 23 '16 at 12:17
  • @ScottThibault Yes, the generator list is hardcoded it the executable and depends for which host OS CMake is build for. And your installation path `/usr/share/cmake-3.2.3` does suggest you are using/running a Linux distribution. On what host OS do you execute CMake? – Florian May 23 '16 at 12:29
  • @ScottThibault I've updated my answer to cover the possible host OS variants. – Florian May 23 '16 at 19:30
0

I guess the pacman build is just broken, so I've resolved this issue by installing the Windows version of CMake from cmake.org with the msi installer.

Scott Thibault
  • 269
  • 2
  • 3
  • 11