Browse Source

cmExperimental: support forwarding associated variables to `try_compile`

Other variables may be needed to make experimental features actually
work. List them with the experimental flag.
Ben Boeckel 2 years ago
parent
commit
aad9033b56
3 changed files with 17 additions and 4 deletions
  1. 3 0
      Source/cmCoreTryCompile.cxx
  2. 12 4
      Source/cmExperimental.cxx
  3. 2 0
      Source/cmExperimental.h

+ 3 - 0
Source/cmCoreTryCompile.cxx

@@ -1084,6 +1084,9 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
            arguments.CMakeInternal != "ABI"_s &&
            arguments.CMakeInternal != "FEATURE_TESTING"_s)) {
         vars.insert(data.Variable);
+        for (auto const& var : data.TryCompileVariables) {
+          vars.insert(var);
+        }
       }
     }
 

+ 12 - 4
Source/cmExperimental.cxx

@@ -20,17 +20,25 @@ namespace {
  */
 cmExperimental::FeatureData LookupTable[] = {
   // CxxModuleCMakeApi
-  { "CxxModuleCMakeApi", "bf70d4b0-9fb7-465c-9803-34014e70d112",
+  { "CxxModuleCMakeApi",
+    "bf70d4b0-9fb7-465c-9803-34014e70d112",
     "CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API",
     "CMake's C++ module support is experimental. It is meant only for "
     "experimentation and feedback to CMake developers.",
-    cmExperimental::TryCompileCondition::SkipCompilerChecks, false },
+    { "CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE",
+      "CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT",
+      "CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG" },
+    cmExperimental::TryCompileCondition::SkipCompilerChecks,
+    false },
   // WindowsKernelModeDriver
-  { "WindowsKernelModeDriver", "5c2d848d-4efa-4529-a768-efd57171bf68",
+  { "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.",
-    cmExperimental::TryCompileCondition::Always, false },
+    {},
+    cmExperimental::TryCompileCondition::Always,
+    false },
 };
 static_assert(sizeof(LookupTable) / sizeof(LookupTable[0]) ==
                 static_cast<size_t>(cmExperimental::Feature::Sentinel),

+ 2 - 0
Source/cmExperimental.h

@@ -6,6 +6,7 @@
 #include "cmConfigure.h" // IWYU pragma: keep
 
 #include <string>
+#include <vector>
 
 class cmMakefile;
 
@@ -33,6 +34,7 @@ public:
     std::string const Uuid;
     std::string const Variable;
     std::string const Description;
+    std::vector<std::string> const TryCompileVariables;
     TryCompileCondition const ForwardThroughTryCompile;
     bool Warned;
   };