MantisBT - CMake
View Issue Details
0015443CMakeCMakepublic2015-03-13 04:422016-05-02 08:30
David Demelier 
Brad King 
highmajoralways
closedfixed 
Windows7
CMake 3.2.1 
CMake 3.3CMake 3.3 
0015443: Unable to use target_compile_features with MinGW-w64
The following CMakeLists.txt generates an error on MinGW-w64:

cmake_minimum_required(VERSION 3.2)
project(test)
 
add_executable(main main.cpp)
 
target_compile_features(
        main
        PRIVATE
                cxx_constexpr
)

This is the error:

CMake Error at CMakeLists.txt:6 (target_compile_features):
  target_compile_features no known features for CXX compiler
 
  "GNU"
 
  version 4.9.2.
1. Try to use target_compile_features with MinGW-w64
It seems that Modules/Compiler/GNU-CXX.cmake has useless UNIX conditionals:

Changing lines 47 and 50 to the following fix the problem:


  set(_result 0)
  if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
    _get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES)
  endif()
  if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
    if (_result EQUAL 0)
      _get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES)
    endif()
    if (_result EQUAL 0)
      _get_gcc_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES)
    endif()
  endif()


Please note that MinGW-w64 fully supports C++11 and C++14.
No tags attached.
related to 0015727closed Brad King Support C compiler features for GNU on windows 
related to 0015897closed Brad King Clang CXX feature detection disabled on WIN32 platforms 
Issue History
2015-03-13 04:42David DemelierNew Issue
2015-03-13 08:24Brad KingTarget Version => CMake 3.3
2015-03-17 14:37Brad KingNote Added: 0038233
2015-03-17 14:37Brad KingAssigned To => Brad King
2015-03-17 14:37Brad KingStatusnew => resolved
2015-03-17 14:37Brad KingResolutionopen => fixed
2015-03-17 14:37Brad KingFixed in Version => CMake 3.3
2015-09-09 09:28Brad KingRelationship addedhas duplicate 0015727
2015-09-09 09:29Brad KingRelationship replacedrelated to 0015727
2016-01-07 15:05Brad KingRelationship addedrelated to 0015897
2016-05-02 08:30Robert MaynardNote Added: 0040994
2016-05-02 08:30Robert MaynardStatusresolved => closed

Notes
(0038233)
Brad King   
2015-03-17 14:37   
I've removed the UNIX conditional. It works for me in local testing with a MinGW GNU 4.6.2 compiler.

 Record compile features for GNU on Windows
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f94727a9 [^]
(0040994)
Robert Maynard   
2016-05-02 08:30   
Closing resolved issues that have not been updated in more than 4 months.