Features: Add cxx_template_template_parameters.
Extend the existing feature infrastructure as needed to support both C++11 and C++98 features.
This commit is contained in:
parent
8472ef243f
commit
a36b957fc4
|
@ -236,3 +236,6 @@ The features known to this version of CMake are:
|
|||
Variadic templates, as defined in N2242_.
|
||||
|
||||
.. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf
|
||||
|
||||
``cxx_template_template_parameters``
|
||||
Template template parameters, as defined in ``ISO/IEC 14882:1998``.
|
||||
|
|
|
@ -3,6 +3,7 @@ set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@")
|
|||
set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
|
||||
set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
|
||||
set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@")
|
||||
set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@")
|
||||
set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@")
|
||||
|
||||
set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
|
||||
|
|
|
@ -17,6 +17,7 @@ function(cmake_determine_compile_features lang)
|
|||
if(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features)
|
||||
message(STATUS "Detecting ${lang} compile features")
|
||||
|
||||
set(CMAKE_CXX98_COMPILE_FEATURES)
|
||||
set(CMAKE_CXX11_COMPILE_FEATURES)
|
||||
|
||||
include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
|
||||
|
@ -28,13 +29,19 @@ function(cmake_determine_compile_features lang)
|
|||
return()
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX98_COMPILE_FEATURES)
|
||||
list(REMOVE_ITEM CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES})
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILE_FEATURES)
|
||||
set(CMAKE_CXX_COMPILE_FEATURES
|
||||
${CMAKE_CXX98_COMPILE_FEATURES}
|
||||
${CMAKE_CXX11_COMPILE_FEATURES}
|
||||
)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_COMPILE_FEATURES ${CMAKE_CXX_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CXX98_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
|
||||
message(STATUS "Detecting ${lang} compile features - done")
|
||||
|
|
|
@ -74,4 +74,5 @@ set(_cmake_feature_test_cxx_extern_templates "${_oldestSupported} && __cplusplus
|
|||
# TODO: Should be supported forever?
|
||||
set(_cmake_feature_test_cxx_func_identifier "${_oldestSupported} && __cplusplus >= 201103L")
|
||||
set(_cmake_feature_test_cxx_variadic_macros "${_oldestSupported} && __cplusplus >= 201103L")
|
||||
set(_cmake_feature_test_cxx_template_template_parameters "${_oldestSupported} && __cplusplus >= 199711L")
|
||||
set(_oldestSupported)
|
||||
|
|
|
@ -27,10 +27,14 @@ endif()
|
|||
macro(cmake_record_cxx_compile_features)
|
||||
macro(_get_gcc_features std_version list)
|
||||
record_compiler_features(CXX "-std=${std_version}" ${list})
|
||||
if (NOT _result EQUAL 0)
|
||||
return()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
||||
_get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
|
||||
_get_gcc_features(c++98 CMAKE_CXX98_COMPILE_FEATURES)
|
||||
else()
|
||||
set(_result 0)
|
||||
endif()
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
F(cxx_sizeof_member) \
|
||||
F(cxx_static_assert) \
|
||||
F(cxx_strong_enums) \
|
||||
F(cxx_template_template_parameters) \
|
||||
F(cxx_thread_local) \
|
||||
F(cxx_trailing_return_types) \
|
||||
F(cxx_unicode_literals) \
|
||||
|
@ -4626,8 +4627,16 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
|
|||
|
||||
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
|
||||
|
||||
bool needCxx98 = false;
|
||||
bool needCxx11 = false;
|
||||
|
||||
if (const char *propCxx98 =
|
||||
this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES"))
|
||||
{
|
||||
std::vector<std::string> props;
|
||||
cmSystemTools::ExpandListArgument(propCxx98, props);
|
||||
needCxx98 = std::find(props.begin(), props.end(), feature) != props.end();
|
||||
}
|
||||
if (const char *propCxx11 =
|
||||
this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES"))
|
||||
{
|
||||
|
@ -4655,6 +4664,7 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
|
|||
cmStrCmp(existingCxxStandard))
|
||||
: cmArrayEnd(CXX_STANDARDS);
|
||||
|
||||
bool setCxx98 = needCxx98 && !existingCxxStandard;
|
||||
bool setCxx11 = needCxx11 && !existingCxxStandard;
|
||||
|
||||
if (needCxx11 && existingCxxStandard && existingCxxIt <
|
||||
|
@ -4664,10 +4674,21 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
|
|||
{
|
||||
setCxx11 = true;
|
||||
}
|
||||
else if(needCxx98 && existingCxxStandard && existingCxxIt <
|
||||
std::find_if(cmArrayBegin(CXX_STANDARDS),
|
||||
cmArrayEnd(CXX_STANDARDS),
|
||||
cmStrCmp("98")))
|
||||
{
|
||||
setCxx98 = true;
|
||||
}
|
||||
|
||||
if (setCxx11)
|
||||
{
|
||||
target->SetProperty("CXX_STANDARD", "11");
|
||||
}
|
||||
else if (setCxx98)
|
||||
{
|
||||
target->SetProperty("CXX_STANDARD", "98");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
template<template <typename> class T, typename U>
|
||||
void someFunc(T<U>)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct A
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
void otherFunc()
|
||||
{
|
||||
A<int> a;
|
||||
someFunc(a);
|
||||
}
|
|
@ -26,6 +26,7 @@ CMAKE_CXX11_STANDARD_COMPILE_OPTION == "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}"
|
|||
CMAKE_CXX98_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}"
|
||||
CMAKE_CXX11_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}"
|
||||
CMAKE_CXX_COMPILE_FEATURES == "${CMAKE_CXX_COMPILE_FEATURES}"
|
||||
CMAKE_CXX98_COMPILE_FEATURES == "${CMAKE_CXX98_COMPILE_FEATURES}"
|
||||
CMAKE_CXX11_COMPILE_FEATURES == "${CMAKE_CXX11_COMPILE_FEATURES}"
|
||||
|
||||
// C shared library flag
|
||||
|
|
Loading…
Reference in New Issue