Merge topic 'feature-record-msvc'
d3489bdb
Features: Record for MSVC 2010-20153228fc50
Features: Define meaning for no language standard default
This commit is contained in:
commit
edc9ff9422
|
@ -80,7 +80,9 @@ When adding the first supported feature to a particular CompilerId, it is
|
||||||
necessary to list support for all features known to cmake (See
|
necessary to list support for all features known to cmake (See
|
||||||
:variable:`CMAKE_C_COMPILE_FEATURES` and
|
:variable:`CMAKE_C_COMPILE_FEATURES` and
|
||||||
:variable:`CMAKE_CXX_COMPILE_FEATURES` as appropriate), where available for
|
:variable:`CMAKE_CXX_COMPILE_FEATURES` as appropriate), where available for
|
||||||
the compiler.
|
the compiler. Furthermore, set ``CMAKE_<LANG>_STANDARD_DEFAULT`` to the
|
||||||
|
default language standard level the compiler uses, or to the empty string
|
||||||
|
if the compiler has no notion of standard levels (such as ``MSVC``).
|
||||||
|
|
||||||
It is sensible to record the features for the most recent version of a
|
It is sensible to record the features for the most recent version of a
|
||||||
particular CompilerId first, and then work backwards. It is sensible to
|
particular CompilerId first, and then work backwards. It is sensible to
|
||||||
|
|
|
@ -5,7 +5,8 @@ The C++ standard whose features are requested to build this target.
|
||||||
|
|
||||||
This property specifies the C++ standard whose features are requested
|
This property specifies the C++ standard whose features are requested
|
||||||
to build this target. For some compilers, this results in adding a
|
to build this target. For some compilers, this results in adding a
|
||||||
flag such as ``-std=gnu++11`` to the compile line.
|
flag such as ``-std=gnu++11`` to the compile line. For compilers that
|
||||||
|
have no notion of a standard level, such as MSVC, this has no effect.
|
||||||
|
|
||||||
Supported values are ``98``, ``11`` and ``14``.
|
Supported values are ``98``, ``11`` and ``14``.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ If this property is set to ``ON``, then the value of the
|
||||||
:prop_tgt:`CXX_STANDARD` target property is treated as a requirement. If this
|
:prop_tgt:`CXX_STANDARD` target property is treated as a requirement. If this
|
||||||
property is ``OFF`` or unset, the :prop_tgt:`CXX_STANDARD` target property is
|
property is ``OFF`` or unset, the :prop_tgt:`CXX_STANDARD` target property is
|
||||||
treated as optional and may "decay" to a previous standard if the requested is
|
treated as optional and may "decay" to a previous standard if the requested is
|
||||||
not available.
|
not available. For compilers that have no notion of a standard level, such as
|
||||||
|
MSVC, this has no effect.
|
||||||
|
|
||||||
See the :manual:`cmake-compile-features(7)` manual for information on
|
See the :manual:`cmake-compile-features(7)` manual for information on
|
||||||
compile features.
|
compile features.
|
||||||
|
|
|
@ -5,7 +5,8 @@ The C standard whose features are requested to build this target.
|
||||||
|
|
||||||
This property specifies the C standard whose features are requested
|
This property specifies the C standard whose features are requested
|
||||||
to build this target. For some compilers, this results in adding a
|
to build this target. For some compilers, this results in adding a
|
||||||
flag such as ``-std=gnu11`` to the compile line.
|
flag such as ``-std=gnu11`` to the compile line. For compilers that
|
||||||
|
have no notion of a standard level, such as MSVC, this has no effect.
|
||||||
|
|
||||||
Supported values are ``90``, ``99`` and ``11``.
|
Supported values are ``90``, ``99`` and ``11``.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ If this property is set to ``ON``, then the value of the
|
||||||
:prop_tgt:`C_STANDARD` target property is treated as a requirement. If this
|
:prop_tgt:`C_STANDARD` target property is treated as a requirement. If this
|
||||||
property is ``OFF`` or unset, the :prop_tgt:`C_STANDARD` target property is
|
property is ``OFF`` or unset, the :prop_tgt:`C_STANDARD` target property is
|
||||||
treated as optional and may "decay" to a previous standard if the requested is
|
treated as optional and may "decay" to a previous standard if the requested is
|
||||||
not available.
|
not available. For compilers that have no notion of a standard level, such as
|
||||||
|
MSVC, this has no effect.
|
||||||
|
|
||||||
See the :manual:`cmake-compile-features(7)` manual for information on
|
See the :manual:`cmake-compile-features(7)` manual for information on
|
||||||
compile features.
|
compile features.
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
feature-record-msvc
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
|
||||||
|
is now aware of features supported by Microsoft Visual Studio (``MSVC``).
|
|
@ -0,0 +1,106 @@
|
||||||
|
|
||||||
|
# Reference: http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx
|
||||||
|
# http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx
|
||||||
|
# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
|
||||||
|
# http://www.visualstudio.com/en-us/news/vs2015-preview-vs.aspx
|
||||||
|
|
||||||
|
|
||||||
|
set(_cmake_oldestSupported "_MSC_VER >= 1600")
|
||||||
|
|
||||||
|
set(MSVC_2015 "_MSC_VER >= 1900")
|
||||||
|
set(_cmake_feature_test_cxx_alignas "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_alignof "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_binary_literals "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_decltype_auto "${MSVC_2015}")
|
||||||
|
# Digit separators are not available as of VS 2015 Preview, but a footnote
|
||||||
|
# says they will be available in the RTM.
|
||||||
|
set(_cmake_feature_test_cxx_digit_separators "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_func_identifier "${MSVC_2015}")
|
||||||
|
# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
|
||||||
|
# Note 1. While previous version of VisualStudio said they supported these
|
||||||
|
# they silently produced bad code, and are now marked as having partial
|
||||||
|
# support in previous versions. The footnote says the support will be complete
|
||||||
|
# in MSVC 2015, so support the feature for that version, assuming that is true.
|
||||||
|
set(_cmake_feature_test_cxx_generalized_initializers "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_nonstatic_member_init "${MSVC_2015}")
|
||||||
|
# Microsoft calls this 'rvalue references v3'
|
||||||
|
set(_cmake_feature_test_cxx_defaulted_move_initializers "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_generic_lambdas "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_inheriting_constructors "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_inline_namespaces "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_lambda_init_captures "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_noexcept "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_return_type_deduction "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_sizeof_member "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_thread_local "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_unicode_literals "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_unrestricted_unions "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_user_literals "${MSVC_2015}")
|
||||||
|
set(_cmake_feature_test_cxx_reference_qualified_functions "${MSVC_2015}")
|
||||||
|
# "The copies and moves don't interact precisely like the Standard says they
|
||||||
|
# should. For example, deletion of moves is specified to also suppress
|
||||||
|
# copies, but Visual C++ in Visual Studio 2013 does not."
|
||||||
|
# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
|
||||||
|
# lists this as 'partial' in 2013
|
||||||
|
set(_cmake_feature_test_cxx_deleted_functions "${MSVC_2015}")
|
||||||
|
|
||||||
|
set(MSVC_2013 "_MSC_VER >= 1800")
|
||||||
|
set(_cmake_feature_test_cxx_alias_templates "${MSVC_2013}")
|
||||||
|
# Microsoft now states they support contextual conversions in 2013 and above.
|
||||||
|
# See footnote 6 at:
|
||||||
|
# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
|
||||||
|
set(_cmake_feature_test_cxx_contextual_conversions "${MSVC_2013}")
|
||||||
|
set(_cmake_feature_test_cxx_default_function_template_args "${MSVC_2013}")
|
||||||
|
set(_cmake_feature_test_cxx_defaulted_functions "${MSVC_2013}")
|
||||||
|
set(_cmake_feature_test_cxx_delegating_constructors "${MSVC_2013}")
|
||||||
|
set(_cmake_feature_test_cxx_explicit_conversions "${MSVC_2013}")
|
||||||
|
set(_cmake_feature_test_cxx_raw_string_literals "${MSVC_2013}")
|
||||||
|
set(_cmake_feature_test_cxx_uniform_initialization "${MSVC_2013}")
|
||||||
|
# Support is documented, but possibly partly broken:
|
||||||
|
# https://msdn.microsoft.com/en-us/library/hh567368.aspx
|
||||||
|
# http://thread.gmane.org/gmane.comp.lib.boost.devel/244986/focus=245333
|
||||||
|
set(_cmake_feature_test_cxx_variadic_templates "${MSVC_2013}")
|
||||||
|
|
||||||
|
set(MSVC_2012 "_MSC_VER >= 1700")
|
||||||
|
set(_cmake_feature_test_cxx_enum_forward_declarations "${MSVC_2012}")
|
||||||
|
set(_cmake_feature_test_cxx_final "${MSVC_2012}")
|
||||||
|
set(_cmake_feature_test_cxx_range_for "${MSVC_2012}")
|
||||||
|
set(_cmake_feature_test_cxx_strong_enums "${MSVC_2012}")
|
||||||
|
|
||||||
|
set(MSVC_2010 "_MSC_VER >= 1600")
|
||||||
|
set(_cmake_feature_test_cxx_auto_type "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_decltype "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_extended_friend_declarations "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_extern_templates "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_lambdas "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_local_type_template_args "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_long_long_type "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_nullptr "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_override "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_right_angle_brackets "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_rvalue_references "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_static_assert "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_template_template_parameters "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_trailing_return_types "${MSVC_2010}")
|
||||||
|
set(_cmake_feature_test_cxx_variadic_macros "${MSVC_2010}")
|
||||||
|
|
||||||
|
# Currently unsupported:
|
||||||
|
# set(_cmake_feature_test_cxx_constexpr )
|
||||||
|
# set(_cmake_feature_test_cxx_relaxed_constexpr )
|
||||||
|
# set(_cmake_feature_test_cxx_attributes )
|
||||||
|
# set(_cmake_feature_test_cxx_attribute_deprecated )
|
||||||
|
# 'NSDMIs for aggregates'
|
||||||
|
# set(_cmake_feature_test_cxx_aggregate_default_initializers )
|
||||||
|
# set(_cmake_feature_test_cxx_variable_templates )
|
||||||
|
|
||||||
|
# In theory decltype incomplete return types was added in 2012
|
||||||
|
# but without support for decltype_auto and return type deduction this
|
||||||
|
# feature is unusable. This remains so as of VS 2015 Preview.
|
||||||
|
# set(_cmake_feature_test_cxx_decltype_incomplete_return_types )
|
||||||
|
|
||||||
|
# Unset all the variables that we don't need exposed.
|
||||||
|
# _cmake_oldestSupported is required by WriteCompilerDetectionHeader
|
||||||
|
set(MSVC_2015)
|
||||||
|
set(MSVC_2013)
|
||||||
|
set(MSVC_2012)
|
||||||
|
set(MSVC_2010)
|
|
@ -0,0 +1,6 @@
|
||||||
|
# MSVC has no specific language level or flags to change it.
|
||||||
|
set(CMAKE_CXX_STANDARD_DEFAULT "")
|
||||||
|
|
||||||
|
macro(cmake_record_cxx_compile_features)
|
||||||
|
record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES)
|
||||||
|
endmacro()
|
|
@ -36,7 +36,7 @@
|
||||||
# PREFIX ClimbingStats
|
# PREFIX ClimbingStats
|
||||||
# OUTPUT_FILES_VAR support_files
|
# OUTPUT_FILES_VAR support_files
|
||||||
# OUTPUT_DIR compilers
|
# OUTPUT_DIR compilers
|
||||||
# COMPILERS GNU Clang
|
# COMPILERS GNU Clang MSVC
|
||||||
# FEATURES cxx_variadic_templates
|
# FEATURES cxx_variadic_templates
|
||||||
# )
|
# )
|
||||||
# install(FILES
|
# install(FILES
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
# write_compiler_detection_header(
|
# write_compiler_detection_header(
|
||||||
# FILE climbingstats_compiler_detection.h
|
# FILE climbingstats_compiler_detection.h
|
||||||
# PREFIX ClimbingStats
|
# PREFIX ClimbingStats
|
||||||
# COMPILERS GNU Clang AppleClang
|
# COMPILERS GNU Clang AppleClang MSVC
|
||||||
# FEATURES cxx_variadic_templates
|
# FEATURES cxx_variadic_templates
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
|
@ -321,6 +321,7 @@ function(write_compiler_detection_header
|
||||||
GNU
|
GNU
|
||||||
Clang
|
Clang
|
||||||
AppleClang
|
AppleClang
|
||||||
|
MSVC
|
||||||
SunPro
|
SunPro
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -528,6 +529,8 @@ function(write_compiler_detection_header
|
||||||
# define ${def_value} alignas(X)
|
# define ${def_value} alignas(X)
|
||||||
# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang
|
# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang
|
||||||
# define ${def_value} __attribute__ ((__aligned__(X)))
|
# define ${def_value} __attribute__ ((__aligned__(X)))
|
||||||
|
# elif ${prefix_arg}_COMPILER_IS_MSVC
|
||||||
|
# define ${def_value} __declspec(align(X))
|
||||||
# else
|
# else
|
||||||
# define ${def_value}
|
# define ${def_value}
|
||||||
# endif
|
# endif
|
||||||
|
@ -540,6 +543,8 @@ function(write_compiler_detection_header
|
||||||
# define ${def_value} alignof(X)
|
# define ${def_value} alignof(X)
|
||||||
# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang
|
# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang
|
||||||
# define ${def_value} __alignof__(X)
|
# define ${def_value} __alignof__(X)
|
||||||
|
# elif ${prefix_arg}_COMPILER_IS_MSVC
|
||||||
|
# define ${def_value} __alignof(X)
|
||||||
# endif
|
# endif
|
||||||
\n")
|
\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1370,6 +1370,8 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
|
||||||
{
|
{
|
||||||
std::vector<std::string> const& langAvailable
|
std::vector<std::string> const& langAvailable
|
||||||
= availableFeatures[lit->first];
|
= availableFeatures[lit->first];
|
||||||
|
const char* standardDefault = context->Makefile
|
||||||
|
->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
|
||||||
for (std::vector<std::string>::const_iterator it = lit->second.begin();
|
for (std::vector<std::string>::const_iterator it = lit->second.begin();
|
||||||
it != lit->second.end(); ++it)
|
it != lit->second.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -1378,6 +1380,12 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
|
||||||
{
|
{
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
if (standardDefault && !*standardDefault)
|
||||||
|
{
|
||||||
|
// This compiler has no notion of language standard levels.
|
||||||
|
// All features known for the language are always available.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!context->Makefile->HaveStandardAvailable(target,
|
if (!context->Makefile->HaveStandardAvailable(target,
|
||||||
lit->first, *it))
|
lit->first, *it))
|
||||||
{
|
{
|
||||||
|
@ -1386,8 +1394,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
|
||||||
const char* l = target->GetProperty(lit->first + "_STANDARD");
|
const char* l = target->GetProperty(lit->first + "_STANDARD");
|
||||||
if (!l)
|
if (!l)
|
||||||
{
|
{
|
||||||
l = context->Makefile
|
l = standardDefault;
|
||||||
->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
|
|
||||||
}
|
}
|
||||||
assert(l);
|
assert(l);
|
||||||
context->MaxLanguageStandard[target][lit->first] = l;
|
context->MaxLanguageStandard[target][lit->first] = l;
|
||||||
|
|
|
@ -2207,6 +2207,13 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const char* defaultStd
|
||||||
|
= this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
|
||||||
|
if (defaultStd && !*defaultStd)
|
||||||
|
{
|
||||||
|
// This compiler has no notion of language standard levels.
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::string stdProp = lang + "_STANDARD";
|
std::string stdProp = lang + "_STANDARD";
|
||||||
const char *standardProp = target->GetProperty(stdProp);
|
const char *standardProp = target->GetProperty(stdProp);
|
||||||
if (!standardProp)
|
if (!standardProp)
|
||||||
|
@ -2269,8 +2276,6 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
|
||||||
std::find(stds.begin(), stds.end(), standard);
|
std::find(stds.begin(), stds.end(), standard);
|
||||||
assert(stdIt != stds.end());
|
assert(stdIt != stds.end());
|
||||||
|
|
||||||
const char* defaultStd
|
|
||||||
= this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
|
|
||||||
std::vector<std::string>::const_iterator defaultStdIt;
|
std::vector<std::string>::const_iterator defaultStdIt;
|
||||||
if (defaultStd)
|
if (defaultStd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5253,6 +5253,27 @@ bool cmMakefile::
|
||||||
HaveCStandardAvailable(cmTarget const* target,
|
HaveCStandardAvailable(cmTarget const* target,
|
||||||
const std::string& feature) const
|
const std::string& feature) const
|
||||||
{
|
{
|
||||||
|
const char* defaultCStandard =
|
||||||
|
this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
|
||||||
|
if (!defaultCStandard)
|
||||||
|
{
|
||||||
|
std::ostringstream e;
|
||||||
|
e << "CMAKE_C_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
|
||||||
|
"not fully configured for this compiler.";
|
||||||
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
||||||
|
// Return true so the caller does not try to lookup the default standard.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
||||||
|
cmStrCmp(defaultCStandard)) == cmArrayEnd(C_STANDARDS))
|
||||||
|
{
|
||||||
|
std::ostringstream e;
|
||||||
|
e << "The CMAKE_C_STANDARD_DEFAULT variable contains an "
|
||||||
|
"invalid value: \"" << defaultCStandard << "\".";
|
||||||
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool needC90 = false;
|
bool needC90 = false;
|
||||||
bool needC99 = false;
|
bool needC99 = false;
|
||||||
bool needC11 = false;
|
bool needC11 = false;
|
||||||
|
@ -5262,7 +5283,7 @@ HaveCStandardAvailable(cmTarget const* target,
|
||||||
const char *existingCStandard = target->GetProperty("C_STANDARD");
|
const char *existingCStandard = target->GetProperty("C_STANDARD");
|
||||||
if (!existingCStandard)
|
if (!existingCStandard)
|
||||||
{
|
{
|
||||||
existingCStandard = this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
|
existingCStandard = defaultCStandard;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
||||||
|
@ -5331,6 +5352,27 @@ bool cmMakefile::IsLaterStandard(std::string const& lang,
|
||||||
bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
|
bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
|
||||||
const std::string& feature) const
|
const std::string& feature) const
|
||||||
{
|
{
|
||||||
|
const char* defaultCxxStandard =
|
||||||
|
this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
|
||||||
|
if (!defaultCxxStandard)
|
||||||
|
{
|
||||||
|
std::ostringstream e;
|
||||||
|
e << "CMAKE_CXX_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
|
||||||
|
"not fully configured for this compiler.";
|
||||||
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
||||||
|
// Return true so the caller does not try to lookup the default standard.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
||||||
|
cmStrCmp(defaultCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
|
||||||
|
{
|
||||||
|
std::ostringstream e;
|
||||||
|
e << "The CMAKE_CXX_STANDARD_DEFAULT variable contains an "
|
||||||
|
"invalid value: \"" << defaultCxxStandard << "\".";
|
||||||
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool needCxx98 = false;
|
bool needCxx98 = false;
|
||||||
bool needCxx11 = false;
|
bool needCxx11 = false;
|
||||||
bool needCxx14 = false;
|
bool needCxx14 = false;
|
||||||
|
@ -5339,7 +5381,7 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
|
||||||
const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
|
const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
|
||||||
if (!existingCxxStandard)
|
if (!existingCxxStandard)
|
||||||
{
|
{
|
||||||
existingCxxStandard = this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
|
existingCxxStandard = defaultCxxStandard;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
||||||
|
|
|
@ -100,6 +100,31 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
|
||||||
|
list(REMOVE_ITEM CXX_non_features
|
||||||
|
# The cxx_contextual_conversions feature happens to work
|
||||||
|
# (for *this* testcase) with VS 2010 and VS 2012, but
|
||||||
|
# they do not document support until VS 2013.
|
||||||
|
cxx_contextual_conversions
|
||||||
|
)
|
||||||
|
elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
|
||||||
|
list(REMOVE_ITEM CXX_non_features
|
||||||
|
# The cxx_deleted_functions and cxx_nonstatic_member_init
|
||||||
|
# features happen to work (for *this* testcase) with VS 2013,
|
||||||
|
# but they do not document support until VS 2015.
|
||||||
|
cxx_deleted_functions
|
||||||
|
cxx_nonstatic_member_init
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
list(REMOVE_ITEM CXX_non_features
|
||||||
|
# The cxx_constexpr feature happens to work (for *this* testcase)
|
||||||
|
# with VS 2015, but they document only partial support.
|
||||||
|
cxx_constexpr
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(C_ext c)
|
set(C_ext c)
|
||||||
set(C_standard_flag 11)
|
set(C_standard_flag 11)
|
||||||
set(CXX_ext cpp)
|
set(CXX_ext cpp)
|
||||||
|
@ -128,6 +153,7 @@ foreach(lang CXX C)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if (CMAKE_C_COMPILE_FEATURES)
|
if (CMAKE_C_COMPILE_FEATURES)
|
||||||
|
if (CMAKE_C_STANDARD_DEFAULT)
|
||||||
string(FIND "${CMAKE_C_FLAGS}" "-std=" std_flag_idx)
|
string(FIND "${CMAKE_C_FLAGS}" "-std=" std_flag_idx)
|
||||||
if (std_flag_idx EQUAL -1)
|
if (std_flag_idx EQUAL -1)
|
||||||
add_executable(default_dialect_C default_dialect.c)
|
add_executable(default_dialect_C default_dialect.c)
|
||||||
|
@ -138,8 +164,10 @@ if (CMAKE_C_COMPILE_FEATURES)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILE_FEATURES)
|
if (CMAKE_CXX_COMPILE_FEATURES)
|
||||||
|
if (CMAKE_CXX_STANDARD_DEFAULT)
|
||||||
string(FIND "${CMAKE_CXX_FLAGS}" "-std=" std_flag_idx)
|
string(FIND "${CMAKE_CXX_FLAGS}" "-std=" std_flag_idx)
|
||||||
if (std_flag_idx EQUAL -1)
|
if (std_flag_idx EQUAL -1)
|
||||||
add_executable(default_dialect default_dialect.cpp)
|
add_executable(default_dialect default_dialect.cpp)
|
||||||
|
@ -149,6 +177,7 @@ if (CMAKE_CXX_COMPILE_FEATURES)
|
||||||
DEFAULT_CXX98=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},98>
|
DEFAULT_CXX98=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},98>
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(CompileFeatures main.cpp)
|
add_executable(CompileFeatures main.cpp)
|
||||||
set_property(TARGET CompileFeatures
|
set_property(TARGET CompileFeatures
|
||||||
|
@ -216,6 +245,29 @@ if (CMAKE_CXX_COMPILE_FEATURES)
|
||||||
-DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
|
-DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
|
||||||
|
add_definitions(
|
||||||
|
-DEXPECT_OVERRIDE_CONTROL=1
|
||||||
|
-DEXPECT_INHERITING_CONSTRUCTORS=1
|
||||||
|
-DEXPECT_FINAL=1
|
||||||
|
-DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
|
||||||
|
)
|
||||||
|
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
|
||||||
|
add_definitions(
|
||||||
|
-DEXPECT_OVERRIDE_CONTROL=1
|
||||||
|
-DEXPECT_INHERITING_CONSTRUCTORS=0
|
||||||
|
-DEXPECT_FINAL=1
|
||||||
|
-DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_definitions(
|
||||||
|
-DEXPECT_OVERRIDE_CONTROL=0
|
||||||
|
-DEXPECT_INHERITING_CONSTRUCTORS=0
|
||||||
|
-DEXPECT_FINAL=0
|
||||||
|
-DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
|
||||||
|
)
|
||||||
|
endif()
|
||||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DEXPECT_OVERRIDE_CONTROL=1
|
-DEXPECT_OVERRIDE_CONTROL=1
|
||||||
|
|
|
@ -11,7 +11,7 @@ get_property(c_known_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
|
||||||
write_compiler_detection_header(
|
write_compiler_detection_header(
|
||||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h"
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h"
|
||||||
PREFIX TEST
|
PREFIX TEST
|
||||||
COMPILERS GNU Clang AppleClang SunPro
|
COMPILERS GNU Clang AppleClang MSVC SunPro
|
||||||
VERSION 3.1
|
VERSION 3.1
|
||||||
PROLOG "// something"
|
PROLOG "// something"
|
||||||
EPILOG "// more"
|
EPILOG "// more"
|
||||||
|
@ -67,6 +67,17 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
||||||
list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
|
list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# for msvc the compiler version determines which c++11 features are available.
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
if(";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;")
|
||||||
|
list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
|
||||||
|
list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
|
||||||
|
else()
|
||||||
|
list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
|
||||||
|
list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
|
||||||
OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
|
OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
|
||||||
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||||
|
@ -84,7 +95,7 @@ write_compiler_detection_header(
|
||||||
PREFIX MULTI
|
PREFIX MULTI
|
||||||
OUTPUT_FILES_VAR multi_files
|
OUTPUT_FILES_VAR multi_files
|
||||||
OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/compiler_support"
|
OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/compiler_support"
|
||||||
COMPILERS GNU Clang AppleClang SunPro
|
COMPILERS GNU Clang AppleClang MSVC SunPro
|
||||||
VERSION 3.1
|
VERSION 3.1
|
||||||
FEATURES
|
FEATURES
|
||||||
${cxx_known_features} ${c_known_features}
|
${cxx_known_features} ${c_known_features}
|
||||||
|
|
|
@ -17,6 +17,8 @@ file(READ
|
||||||
"${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt"
|
"${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt"
|
||||||
CXX_FEATURES
|
CXX_FEATURES
|
||||||
)
|
)
|
||||||
|
include("${RunCMake_BINARY_DIR}/generate_feature_list-build/c_standard_default.cmake")
|
||||||
|
include("${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_standard_default.cmake")
|
||||||
|
|
||||||
if (NOT C_FEATURES)
|
if (NOT C_FEATURES)
|
||||||
run_cmake(NoSupportedCFeatures)
|
run_cmake(NoSupportedCFeatures)
|
||||||
|
@ -27,7 +29,9 @@ if (NOT CXX_FEATURES)
|
||||||
run_cmake(NoSupportedCxxFeatures)
|
run_cmake(NoSupportedCxxFeatures)
|
||||||
run_cmake(NoSupportedCxxFeaturesGenex)
|
run_cmake(NoSupportedCxxFeaturesGenex)
|
||||||
else()
|
else()
|
||||||
|
if(CXX_STANDARD_DEFAULT)
|
||||||
run_cmake(LinkImplementationFeatureCycle)
|
run_cmake(LinkImplementationFeatureCycle)
|
||||||
|
endif()
|
||||||
run_cmake(LinkImplementationFeatureCycleSolved)
|
run_cmake(LinkImplementationFeatureCycleSolved)
|
||||||
|
|
||||||
if (";${CXX_FEATURES};" MATCHES ";cxx_final;")
|
if (";${CXX_FEATURES};" MATCHES ";cxx_final;")
|
||||||
|
@ -38,6 +42,7 @@ else()
|
||||||
unset(RunCMake_TEST_OPTIONS)
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CXX_STANDARD_DEFAULT)
|
||||||
foreach(standard 98 11)
|
foreach(standard 98 11)
|
||||||
file(READ
|
file(READ
|
||||||
"${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx${standard}_flag.txt"
|
"${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx${standard}_flag.txt"
|
||||||
|
@ -52,3 +57,4 @@ foreach(standard 98 11)
|
||||||
run_cmake(RequireCXX${standard}ExtVariable)
|
run_cmake(RequireCXX${standard}ExtVariable)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
|
@ -9,6 +9,20 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt"
|
||||||
"${CMAKE_CXX_COMPILE_FEATURES}"
|
"${CMAKE_CXX_COMPILE_FEATURES}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(DEFINED CMAKE_C_STANDARD_DEFAULT)
|
||||||
|
set(c_standard_default_code "set(C_STANDARD_DEFAULT \"${CMAKE_C_STANDARD_DEFAULT}\")\n")
|
||||||
|
else()
|
||||||
|
set(c_standard_default_code "unset(C_STANDARD_DEFAULT)\n")
|
||||||
|
endif()
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/c_standard_default.cmake" "${c_standard_default_code}")
|
||||||
|
|
||||||
|
if(DEFINED CMAKE_CXX_STANDARD_DEFAULT)
|
||||||
|
set(cxx_standard_default_code "set(CXX_STANDARD_DEFAULT \"${CMAKE_CXX_STANDARD_DEFAULT}\")\n")
|
||||||
|
else()
|
||||||
|
set(cxx_standard_default_code "unset(CXX_STANDARD_DEFAULT)\n")
|
||||||
|
endif()
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_standard_default.cmake" "${cxx_standard_default_code}")
|
||||||
|
|
||||||
foreach(standard 98 11)
|
foreach(standard 98 11)
|
||||||
set(CXX${standard}_FLAG NOTFOUND)
|
set(CXX${standard}_FLAG NOTFOUND)
|
||||||
if (DEFINED CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION)
|
if (DEFINED CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION)
|
||||||
|
|
Loading…
Reference in New Issue