Browse Source

cmExperimental: use an `enum` for whether to forward to try_compile

Ben Boeckel 2 years ago
parent
commit
1a538ae07c
3 changed files with 12 additions and 5 deletions
  1. 2 1
      Source/cmCoreTryCompile.cxx
  2. 3 3
      Source/cmExperimental.cxx
  3. 7 1
      Source/cmExperimental.h

+ 2 - 1
Source/cmCoreTryCompile.cxx

@@ -1077,7 +1077,8 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
          i++) {
       auto const& data = cmExperimental::DataForFeature(
         static_cast<cmExperimental::Feature>(i));
-      if (data.ForwardThroughTryCompile) {
+      if (data.ForwardThroughTryCompile ==
+          cmExperimental::TryCompileCondition::Always) {
         vars.insert(data.Variable);
       }
     }

+ 3 - 3
Source/cmExperimental.cxx

@@ -24,14 +24,14 @@ cmExperimental::FeatureData LookupTable[] = {
     "CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API",
     "CMake's C++ module support is experimental. It is meant only for "
     "experimentation and feedback to CMake developers.",
-    false, // https://gitlab.kitware.com/cmake/cmake/-/issues/25097
-    false },
+    // https://gitlab.kitware.com/cmake/cmake/-/issues/25097
+    cmExperimental::TryCompileCondition::Never, false },
   // WindowsKernelModeDriver
   { "WindowsKernelModeDriver", "5c2d848d-4efa-4529-a768-efd57171bf68",
     "CMAKE_EXPERIMENTAL_WINDOWS_KERNEL_MODE_DRIVER",
     "CMake's Windows kernel-mode driver support is experimental. It is meant "
     "only for experimentation and feedback to CMake developers.",
-    true, false },
+    cmExperimental::TryCompileCondition::Always, false },
 };
 static_assert(sizeof(LookupTable) / sizeof(LookupTable[0]) ==
                 static_cast<size_t>(cmExperimental::Feature::Sentinel),

+ 7 - 1
Source/cmExperimental.h

@@ -20,13 +20,19 @@ public:
     Sentinel,
   };
 
+  enum class TryCompileCondition
+  {
+    Always,
+    Never,
+  };
+
   struct FeatureData
   {
     std::string const Name;
     std::string const Uuid;
     std::string const Variable;
     std::string const Description;
-    bool const ForwardThroughTryCompile;
+    TryCompileCondition const ForwardThroughTryCompile;
     bool Warned;
   };