本文介绍了"CXX编译器的未知功能"使用MSVC ++ 2013编译时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相对简单的CMakeLists.txt,其中包含以下行:

target_compile_features(myapp PRIVATE
    cxx_generalized_initializers
    cxx_lambdas
    cxx_nullptr)

当我在装有MSVC ++ 2013 Express的Windows 2012 Server上运行cmake时,出现以下错误:

CMake Error at CMakeLists.txt:61 (target_compile_features):
  target_compile_features no known features for CXX compiler

  "MSVC"

  version 18.0.30723.0.

是什么导致此错误,我该怎么办?当我在带有GCC的Ubuntu 14.10中构建项目时,CMake似乎没有任何问题.

为了帮助起见,我正在使用CMake 3.1.0(这是第一个支持target_compile_features的CMake版本).

解决方案

CMake 3.1.0仅对GCC 4.7+(在UNIX上但不对APPLE)和Clang(但不对AppleClang)3.4+上支持编译功能". >

CMake 3.2.0将支持范围扩展到GCC 4.4+(在UNIX上,包括APPLE),AppleClang 4.0+(Xcode 4.4 +),SolarisStudio 12.4和MSVC 2010 +.

其他编译器的补丁和维护可以发送到cmake邮件列表.

如果您在APPLE上,请确保CMP0025NEW.

https://cmake.org/cmake/help/v3 .6/command/cmake_policy.html

I have a relatively simple CMakeLists.txt that contains the following line(s):

target_compile_features(myapp PRIVATE
    cxx_generalized_initializers
    cxx_lambdas
    cxx_nullptr)

When I run cmake on a Windows 2012 Server with MSVC++ 2013 Express installed, I get the following error:

CMake Error at CMakeLists.txt:61 (target_compile_features):
  target_compile_features no known features for CXX compiler

  "MSVC"

  version 18.0.30723.0.

What is causing this error, and what can I do about it? CMake doesn't seem to have any problems when I build the project in Ubuntu 14.10 with GCC.

I am using CMake 3.1.0, in case that helps (it was the first CMake release to support target_compile_features).

解决方案

CMake 3.1.0 only supports 'compile features' for GCC 4.7+ (on UNIX but not APPLE) and Clang (but not AppleClang) 3.4+.

CMake 3.2.0 will extend the support to GCC 4.4+ (on UNIX, including APPLE), AppleClang 4.0+ (Xcode 4.4+), SolarisStudio 12.4 and MSVC 2010+.

Patches and maintenance for other compilers can be sent to the cmake mailing list.

Make sure CMP0025 is NEW if you are on APPLE.

https://cmake.org/cmake/help/v3.6/command/cmake_policy.html

这篇关于"CXX编译器的未知功能"使用MSVC ++ 2013编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 05:14