diff options
| author | ruki <[email protected]> | 2017-07-06 06:14:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-06 06:14:27 +0800 |
| commit | 7542ee16e224851e9e1832102a2756b0a9e4082c (patch) | |
| tree | 50ef2e9646d5d2bc3e54c9d7705456d9d4cefc09 | |
| parent | a1bdaeab96b1c3a877b17a6511d4adfaab8327f1 (diff) | |
add c++ features for clang
| -rw-r--r-- | xmake/modules/detect/tools/clang/cxxfeatures.lua | 80 |
1 files changed, 78 insertions, 2 deletions
diff --git a/xmake/modules/detect/tools/clang/cxxfeatures.lua b/xmake/modules/detect/tools/clang/cxxfeatures.lua index e458a2308..93d18e090 100644 --- a/xmake/modules/detect/tools/clang/cxxfeatures.lua +++ b/xmake/modules/detect/tools/clang/cxxfeatures.lua @@ -36,8 +36,84 @@ function main() -- init features _g.features = cxxfeatures() - -- TODO - -- set("", "") + -- init conditions + local clang_minver = "((__clang_major__ * 100) + __clang_minor__) >= 301" + local clang34_cxx14 = "((__clang_major__ * 100) + __clang_minor__) >= 304 && __cplusplus > 201103L" + local clang31_cxx11 = clang_minver .. " && __cplusplus >= 201103L" + local clang29_cxx11 = clang_minver .. " && __cplusplus >= 201103L" + local clang_cxx98 = clang_minver .. " && __cplusplus >= 199711L" + + -- set features for __has_feature() + local features_of_has_feature = + { + "cxx_alias_templates" + , "cxx_alignas" + , "cxx_attributes" + , "cxx_auto_type" + , "cxx_binary_literals" + , "cxx_constexpr" + , "cxx_contextual_conversions" + , "cxx_decltype" + , "cxx_default_function_template_args" + , "cxx_defaulted_functions" + , "cxx_delegating_constructors" + , "cxx_deleted_functions" + , "cxx_explicit_conversions" + , "cxx_generalized_initializers" + , "cxx_inheriting_constructors" + , "cxx_lambdas" + , "cxx_local_type_template_args" + , "cxx_noexcept" + , "cxx_nonstatic_member_init" + , "cxx_nullptr" + , "cxx_range_for" + , "cxx_raw_string_literals" + , "cxx_reference_qualified_functions" + , "cxx_relaxed_constexpr" + , "cxx_return_type_deduction" + , "cxx_rvalue_references" + , "cxx_static_assert" + , "cxx_strong_enums" + , "cxx_thread_local" + , "cxx_unicode_literals" + , "cxx_unrestricted_unions" + , "cxx_user_literals" + , "cxx_variable_templates" + , "cxx_variadic_templates" + , {"cxx_aggregate_default_initializers", "cxx_aggregate_nsdmi" } + , {"cxx_trailing_return_types", "cxx_trailing_return" } + , {"cxx_alignof", "cxx_alignas" } + , {"cxx_final", "cxx_override_control" } + , {"cxx_override", "cxx_override_control" } + , {"cxx_uniform_initialization", "cxx_generalized_initializers" } + , {"cxx_defaulted_move_initializers", "cxx_defaulted_functions" } + , {"cxx_lambda_init_captures", "cxx_init_captures" } + } + for _, feature in ipairs(features_of_has_feature) do + local name = feature + local test = feature + if type(feature) == "table" then + name = feature[1] + test = feature[2] + end + _set(name, clang_minver .. " && __has_feature(" .. test .. ")") + end + + -- set features + _set("cxx_attribute_deprecated", clang34_cxx14) -- http://llvm.org/bugs/show_bug.cgi?id=19242 + _set("cxx_decltype_auto", clang34_cxx14) -- http://llvm.org/bugs/show_bug.cgi?id=19698 + _set("cxx_digit_separators", clang34_cxx14) + _set("cxx_generic_lambdas", clang34_cxx14) -- http://llvm.org/bugs/show_bug.cgi?id=19674 + _set("cxx_enum_forward_declarations", clang31_cxx11) + _set("cxx_sizeof_member", clang31_cxx11) + _set("cxx_extended_friend_declarations", clang29_cxx11) + _set("cxx_extern_templates", clang29_cxx11) + _set("cxx_func_identifier", clang29_cxx11) + _set("cxx_inline_namespaces", clang29_cxx11) + _set("cxx_long_long_type", clang29_cxx11) + _set("cxx_right_angle_brackets", clang29_cxx11) + _set("cxx_variadic_macros", clang29_cxx11) + _set("cxx_template_template_parameters", clang_cxx98) -- get features return _g.features |
