[Cmake-commits] CMake branch, next, updated. v3.1.1-2400-ga64545d

Brad King brad.king at kitware.com
Tue Jan 27 12:29:26 EST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  a64545de6ce4da2f2dc50deecc632ccf8e2d4ef8 (commit)
       via  d3e921ef87838fff6b8778966fc2fc530638a831 (commit)
       via  3837f15096592ee85e4a459b11fccf0722a7318f (commit)
      from  4457266e0b54b8b0bbe65bb58637b53e4e03a0c2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a64545de6ce4da2f2dc50deecc632ccf8e2d4ef8
commit a64545de6ce4da2f2dc50deecc632ccf8e2d4ef8
Merge: 4457266 d3e921e
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 27 12:29:25 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jan 27 12:29:25 2015 -0500

    Merge topic 'feature-record-msvc' into next
    
    d3e921ef Features: Record for MSVC 2010-2015
    3837f150 Features: Define meaning for no language standard default


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d3e921ef87838fff6b8778966fc2fc530638a831
commit d3e921ef87838fff6b8778966fc2fc530638a831
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Mon Jan 19 15:49:06 2015 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jan 27 10:44:53 2015 -0500

    Features: Record for MSVC 2010-2015
    
    Notes:
    
    * Initializer lists are only properly supported in 2015 and above.
      Previous Visual Studio releases said they supported initializer lists.
    
    * VS2012 and above conform to cxx_decltype_incomplete_return_types
      proposal but without support for auto return types the feature is
      unusable.  Activate support only in VS2015 and above.
    
    * VS2010 and above to conform to the updated cxx_contextual_conversions
      proposal.
    
    * In WCDH add MSVC Compatibility for cxx_align{of,as}.
    
    Co-Author: Stephen Kelly <steveire at gmail.com>

diff --git a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..476f244
--- /dev/null
+++ b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
@@ -0,0 +1,100 @@
+
+# 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}")
+# In theory decltype incomplete return types was added in 2012
+# but without support for decltype_auto and return type deduction this
+# feature is unusable
+set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${MSVC_2015}")
+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 this
+# they silently produced bad code, and are now marked as having partial
+# support
+set(_cmake_feature_test_cxx_generalized_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(MSVC_2013 "_MSC_VER >= 1800")
+set(_cmake_feature_test_cxx_alias_templates "${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_deleted_functions "${MSVC_2013}")
+set(_cmake_feature_test_cxx_explicit_conversions "${MSVC_2013}")
+set(_cmake_feature_test_cxx_nonstatic_member_init "${MSVC_2013}")
+set(_cmake_feature_test_cxx_raw_string_literals "${MSVC_2013}")
+set(_cmake_feature_test_cxx_uniform_initialization "${MSVC_2013}")
+# Possibly broken:
+# 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_function "${MSVC_2010}")
+set(_cmake_feature_test_cxx_auto_type "${MSVC_2010}")
+# Microsoft now states they support contextual conversions
+# 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_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:
+# http://herbsutter.com/2013/11/18/visual-c-compiler-november-2013-ctp/
+# 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_reference_qualified_functions )
+# set(_cmake_feature_test_cxx_constexpr )
+# set(_cmake_feature_test_cxx_attributes )
+# set(_cmake_feature_test_cxx_aggregate_default_initializers )
+# set(_cmake_feature_test_cxx_attribute_deprecated )
+# set(_cmake_feature_test_cxx_defaulted_move_initializers )
+# set(_cmake_feature_test_cxx_nonstatic_member_init )
+# set(_cmake_feature_test_cxx_relaxed_constexpr )
+# set(_cmake_feature_test_cxx_variable_templates )
+
+
+# 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)
diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake
new file mode 100644
index 0000000..962aaeb
--- /dev/null
+++ b/Modules/Compiler/MSVC-CXX.cmake
@@ -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()
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index e81bc08..d18f47c 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -36,7 +36,7 @@
 #      PREFIX ClimbingStats
 #      OUTPUT_FILES_VAR support_files
 #      OUTPUT_DIR compilers
-#      COMPILERS GNU Clang
+#      COMPILERS GNU Clang MSVC
 #      FEATURES cxx_variadic_templates
 #    )
 #    install(FILES
@@ -100,7 +100,7 @@
 #    write_compiler_detection_header(
 #      FILE climbingstats_compiler_detection.h
 #      PREFIX ClimbingStats
-#      COMPILERS GNU Clang AppleClang
+#      COMPILERS GNU Clang AppleClang MSVC
 #      FEATURES cxx_variadic_templates
 #    )
 #
@@ -321,6 +321,7 @@ function(write_compiler_detection_header
     GNU
     Clang
     AppleClang
+    MSVC
     SunPro
   )
 
@@ -528,6 +529,8 @@ function(write_compiler_detection_header
 #    define ${def_value} alignas(X)
 #  elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang
 #    define ${def_value} __attribute__ ((__aligned__(X)))
+#  elif ${prefix_arg}_COMPILER_IS_MSVC
+#    define ${def_value} __declspec(align(X))
 #  else
 #    define ${def_value}
 #  endif
@@ -540,6 +543,8 @@ function(write_compiler_detection_header
 #    define ${def_value} alignof(X)
 #  elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang
 #    define ${def_value} __alignof__(X)
+#  elif ${prefix_arg}_COMPILER_IS_MSVC
+#    define ${def_value} __alignof(X)
 #  endif
 \n")
       endif()
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index a8b85d6..5f8fbc0 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -211,6 +211,29 @@ if (CMAKE_CXX_COMPILE_FEATURES)
         -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
       )
     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")
     add_definitions(
       -DEXPECT_OVERRIDE_CONTROL=1
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
index b5e46c0..43e89ab 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -11,7 +11,7 @@ get_property(c_known_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
 write_compiler_detection_header(
   FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h"
   PREFIX TEST
-  COMPILERS GNU Clang AppleClang SunPro
+  COMPILERS GNU Clang AppleClang MSVC SunPro
   VERSION 3.1
   PROLOG "// something"
   EPILOG "// more"
@@ -67,6 +67,18 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
   list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
 endif()
 
+# for msvc the compiler version determines which c++11 features are available.
+# Both variadic templates and delegating constructors support exist in
+# all versions that we write compile headers for.
+if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
+    ";${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(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+  list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
+  list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
+endif()
+
 if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
     OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
     OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
@@ -84,7 +96,7 @@ write_compiler_detection_header(
   PREFIX MULTI
   OUTPUT_FILES_VAR multi_files
   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
   FEATURES
     ${cxx_known_features} ${c_known_features}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3837f15096592ee85e4a459b11fccf0722a7318f
commit 3837f15096592ee85e4a459b11fccf0722a7318f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Jan 26 16:42:36 2015 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jan 27 10:44:53 2015 -0500

    Features: Define meaning for no language standard default
    
    Define an empty string in CMAKE_<LANG>_STANDARD_DEFAULT to mean that
    the toolchain has no notion of lanuage standard levels.  In this case
    the <LANG>_STANDARD[_REQUIRED] properties will have no effect.
    
    Update the RunCMake.CompileFeatures test to exclude the
    LinkImplementationFeatureCycle test when there is no standard default.
    It can never fail because no use of specific features will adjust the
    CXX_STANDARD level required for any target since the standard levels
    have no meaning in this case.

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 834f705..af4c950 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2207,6 +2207,13 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
     {
     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";
   const char *standardProp = target->GetProperty(stdProp);
   if (!standardProp)
@@ -2269,8 +2276,6 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
                                 std::find(stds.begin(), stds.end(), standard);
   assert(stdIt != stds.end());
 
-  const char* defaultStd
-      = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
   std::vector<std::string>::const_iterator defaultStdIt;
   if (defaultStd)
     {
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 87e62d7..b5ff732 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -5253,6 +5253,33 @@ bool cmMakefile::
 HaveCStandardAvailable(cmTarget const* target,
                        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 (!*defaultCStandard)
+    {
+    // This compiler has no notion of language standard levels.
+    // All features known for the language are always available.
+    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 needC99 = false;
   bool needC11 = false;
@@ -5262,7 +5289,7 @@ HaveCStandardAvailable(cmTarget const* target,
   const char *existingCStandard = target->GetProperty("C_STANDARD");
   if (!existingCStandard)
     {
-    existingCStandard = this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+    existingCStandard = defaultCStandard;
     }
 
   if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
@@ -5331,6 +5358,33 @@ bool cmMakefile::IsLaterStandard(std::string const& lang,
 bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
                                          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 (!*defaultCxxStandard)
+    {
+    // This compiler has no notion of language standard levels.
+    // All features known for the language are always available.
+    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 needCxx11 = false;
   bool needCxx14 = false;
@@ -5339,7 +5393,7 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
   const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
   if (!existingCxxStandard)
     {
-    existingCxxStandard = this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+    existingCxxStandard = defaultCxxStandard;
     }
 
   if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index 5cd0836..a8b85d6 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -119,26 +119,30 @@ foreach(lang CXX C)
 endforeach()
 
 if (CMAKE_C_COMPILE_FEATURES)
-  string(FIND "${CMAKE_C_FLAGS}" "-std=" std_flag_idx)
-  if (std_flag_idx EQUAL -1)
-    add_executable(default_dialect_C default_dialect.c)
-    target_compile_definitions(default_dialect_C PRIVATE
-      DEFAULT_C11=$<EQUAL:${CMAKE_C_STANDARD_DEFAULT},11>
-      DEFAULT_C99=$<EQUAL:${CMAKE_C_STANDARD_DEFAULT},99>
-      DEFAULT_C90=$<EQUAL:${CMAKE_C_STANDARD_DEFAULT},90>
-    )
+  if (CMAKE_C_STANDARD_DEFAULT)
+    string(FIND "${CMAKE_C_FLAGS}" "-std=" std_flag_idx)
+    if (std_flag_idx EQUAL -1)
+      add_executable(default_dialect_C default_dialect.c)
+      target_compile_definitions(default_dialect_C PRIVATE
+        DEFAULT_C11=$<EQUAL:${CMAKE_C_STANDARD_DEFAULT},11>
+        DEFAULT_C99=$<EQUAL:${CMAKE_C_STANDARD_DEFAULT},99>
+        DEFAULT_C90=$<EQUAL:${CMAKE_C_STANDARD_DEFAULT},90>
+      )
+    endif()
   endif()
 endif()
 
 if (CMAKE_CXX_COMPILE_FEATURES)
-  string(FIND "${CMAKE_CXX_FLAGS}" "-std=" std_flag_idx)
-  if (std_flag_idx EQUAL -1)
-    add_executable(default_dialect default_dialect.cpp)
-    target_compile_definitions(default_dialect PRIVATE
-      DEFAULT_CXX14=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},14>
-      DEFAULT_CXX11=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},11>
-      DEFAULT_CXX98=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},98>
-    )
+  if (CMAKE_CXX_STANDARD_DEFAULT)
+    string(FIND "${CMAKE_CXX_FLAGS}" "-std=" std_flag_idx)
+    if (std_flag_idx EQUAL -1)
+      add_executable(default_dialect default_dialect.cpp)
+      target_compile_definitions(default_dialect PRIVATE
+        DEFAULT_CXX14=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},14>
+        DEFAULT_CXX11=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},11>
+        DEFAULT_CXX98=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},98>
+      )
+    endif()
   endif()
 
   add_executable(CompileFeatures main.cpp)
diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
index 1892a5c..efea371 100644
--- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
@@ -17,6 +17,8 @@ file(READ
   "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt"
   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)
   run_cmake(NoSupportedCFeatures)
@@ -27,7 +29,9 @@ if (NOT CXX_FEATURES)
   run_cmake(NoSupportedCxxFeatures)
   run_cmake(NoSupportedCxxFeaturesGenex)
 else()
-  run_cmake(LinkImplementationFeatureCycle)
+  if(CXX_STANDARD_DEFAULT)
+    run_cmake(LinkImplementationFeatureCycle)
+  endif()
   run_cmake(LinkImplementationFeatureCycleSolved)
 
   if (";${CXX_FEATURES};" MATCHES ";cxx_final;")
@@ -38,17 +42,19 @@ else()
   unset(RunCMake_TEST_OPTIONS)
 endif()
 
-foreach(standard 98 11)
-  file(READ
-    "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx${standard}_flag.txt"
-    CXX${standard}_FLAG
-  )
-  if (CXX${standard}_FLAG STREQUAL NOTFOUND)
-    run_cmake(RequireCXX${standard})
-    run_cmake(RequireCXX${standard}Variable)
-  endif()
-  if (CXX${standard}EXT_FLAG STREQUAL NOTFOUND)
-    run_cmake(RequireCXX${standard}Ext)
-    run_cmake(RequireCXX${standard}ExtVariable)
-  endif()
-endforeach()
+if(CXX_STANDARD_DEFAULT)
+  foreach(standard 98 11)
+    file(READ
+      "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx${standard}_flag.txt"
+      CXX${standard}_FLAG
+    )
+    if (CXX${standard}_FLAG STREQUAL NOTFOUND)
+      run_cmake(RequireCXX${standard})
+      run_cmake(RequireCXX${standard}Variable)
+    endif()
+    if (CXX${standard}EXT_FLAG STREQUAL NOTFOUND)
+      run_cmake(RequireCXX${standard}Ext)
+      run_cmake(RequireCXX${standard}ExtVariable)
+    endif()
+  endforeach()
+endif()
diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
index 09e17b1..5c58052 100644
--- a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
+++ b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
@@ -9,6 +9,20 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt"
   "${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)
   set(CXX${standard}_FLAG NOTFOUND)
   if (DEFINED CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION)

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list