Search code examples
windowsc++11cmakemingw-w64msys2

target_compile_features fails on MinGW-w64 in MSYS2


I recently installed MSYS2 on Windows, along with the MinGW-w64 toolchain and CMake. Specifically, I used the following packages:

  • mingw-w64-i686-gcc
  • mingw-w64-i686-cmake
  • make

Trouble is, whenever I invoke CMake from within the MSYS2 shell with cmake -G"MSYS Makefiles", it fails with the following:

target_compile_features no known features for CXX compiler

"GNU"

version 4.9.2.

The line in CMakeLists.txt that generates the error is this: target_compile_features(myproject PUBLIC cxx_decltype).

If I run CMake from outside the MSYS2 shell (I also have it installed separately) with the "MinGW Makefiles" generator, the makefile generation succeeds.

Inside MSYS2, the CMake version is 3.2.3. The version outside is 3.3.0.

Is there any way to resolve this issue? Thanks in advance.


Solution

  • There was bug about interaction of compile features mechanism in CMake 3.3 with gcc 4.8+: https://public.kitware.com/Bug/view.php?id=15443. It have been fixed several months ago. You need that fix being applied.