cmExperimental.cxx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmExperimental.h"
  4. #include <cassert>
  5. #include <cstddef>
  6. #include <string>
  7. #include "cmMakefile.h"
  8. #include "cmMessageType.h"
  9. #include "cmValue.h"
  10. namespace {
  11. /*
  12. * The `Uuid` fields of these objects should change periodically.
  13. * Search for other instances to keep the documentation and test suite
  14. * up-to-date.
  15. */
  16. cmExperimental::FeatureData LookupTable[] = {
  17. // CxxModuleCMakeApi
  18. { "CxxModuleCMakeApi",
  19. "ac01f462-0f5f-432a-86aa-acef252918a6",
  20. "CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API",
  21. "CMake's C++ module support is experimental. It is meant only for "
  22. "experimentation and feedback to CMake developers.",
  23. { "CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE",
  24. "CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT",
  25. "CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG" },
  26. cmExperimental::TryCompileCondition::SkipCompilerChecks,
  27. false },
  28. // WindowsKernelModeDriver
  29. { "WindowsKernelModeDriver",
  30. "5c2d848d-4efa-4529-a768-efd57171bf68",
  31. "CMAKE_EXPERIMENTAL_WINDOWS_KERNEL_MODE_DRIVER",
  32. "CMake's Windows kernel-mode driver support is experimental. It is meant "
  33. "only for experimentation and feedback to CMake developers.",
  34. {},
  35. cmExperimental::TryCompileCondition::Always,
  36. false },
  37. };
  38. static_assert(sizeof(LookupTable) / sizeof(LookupTable[0]) ==
  39. static_cast<size_t>(cmExperimental::Feature::Sentinel),
  40. "Experimental feature lookup table mismatch");
  41. cmExperimental::FeatureData& DataForFeature(cmExperimental::Feature f)
  42. {
  43. assert(f != cmExperimental::Feature::Sentinel);
  44. return LookupTable[static_cast<size_t>(f)];
  45. }
  46. }
  47. const cmExperimental::FeatureData& cmExperimental::DataForFeature(Feature f)
  48. {
  49. return ::DataForFeature(f);
  50. }
  51. bool cmExperimental::HasSupportEnabled(cmMakefile const& mf, Feature f)
  52. {
  53. bool enabled = false;
  54. auto& data = ::DataForFeature(f);
  55. auto value = mf.GetDefinition(data.Variable);
  56. if (value == data.Uuid) {
  57. enabled = true;
  58. }
  59. if (enabled && !data.Warned) {
  60. mf.IssueMessage(MessageType::AUTHOR_WARNING, data.Description);
  61. data.Warned = true;
  62. }
  63. return enabled;
  64. }