[CMake] target_compile_features no known features for CXX compiler for clang 9.0

Brad King brad.king at kitware.com
Mon Mar 26 09:55:45 EDT 2018


On 03/20/2018 08:52 PM, Rick Mann wrote:
> Xcode (Version 9.2 (9C40b))

That works with CMake 3.11.0-rc4 AFAIK.

> CMake Error at cmake/AddCeresCXX11RequirementsToTarget.cmake:70 (target_compile_features):
>   target_compile_features no known features for CXX compiler
> 
>   "Clang"
> 
>   version 9.0.0.9000039.

The compiler id should be AppleClang to work with compiler features,
but that is controlled by policy CMP0025:

  https://cmake.org/cmake/help/v3.11/policy/CMP0025.html

As of Ceres 1.14.0 they are not setting that policy to NEW:

  https://github.com/ceres-solver/ceres-solver/blob/1.14.0/CMakeLists.txt#L32-L40

That is necessary for this code:

  https://github.com/ceres-solver/ceres-solver/blob/1.14.0/cmake/AddCeresCXX11RequirementsToTarget.cmake#L58-L71

to work, since the target_compile_features command expects
behavior as of CMake 3.1 or above.  Typically the command
would only be used after `cmake_minimum_required(VERSION 3.1)`
which would automatically set CMP0025 to NEW.

Ceres is trying to support older CMake versions and so would
need to set the policy manually.

-Brad


More information about the CMake mailing list