cmExperimental.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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", "bf70d4b0-9fb7-465c-9803-34014e70d112",
  19. "CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API",
  20. "CMake's C++ module support is experimental. It is meant only for "
  21. "experimentation and feedback to CMake developers.",
  22. // https://gitlab.kitware.com/cmake/cmake/-/issues/25097
  23. cmExperimental::TryCompileCondition::Never, false },
  24. // WindowsKernelModeDriver
  25. { "WindowsKernelModeDriver", "5c2d848d-4efa-4529-a768-efd57171bf68",
  26. "CMAKE_EXPERIMENTAL_WINDOWS_KERNEL_MODE_DRIVER",
  27. "CMake's Windows kernel-mode driver support is experimental. It is meant "
  28. "only for experimentation and feedback to CMake developers.",
  29. cmExperimental::TryCompileCondition::Always, false },
  30. };
  31. static_assert(sizeof(LookupTable) / sizeof(LookupTable[0]) ==
  32. static_cast<size_t>(cmExperimental::Feature::Sentinel),
  33. "Experimental feature lookup table mismatch");
  34. cmExperimental::FeatureData& DataForFeature(cmExperimental::Feature f)
  35. {
  36. assert(f != cmExperimental::Feature::Sentinel);
  37. return LookupTable[static_cast<size_t>(f)];
  38. }
  39. }
  40. const cmExperimental::FeatureData& cmExperimental::DataForFeature(Feature f)
  41. {
  42. return ::DataForFeature(f);
  43. }
  44. bool cmExperimental::HasSupportEnabled(cmMakefile const& mf, Feature f)
  45. {
  46. bool enabled = false;
  47. auto& data = ::DataForFeature(f);
  48. auto value = mf.GetDefinition(data.Variable);
  49. if (value == data.Uuid) {
  50. enabled = true;
  51. }
  52. if (enabled && !data.Warned) {
  53. mf.IssueMessage(MessageType::AUTHOR_WARNING, data.Description);
  54. data.Warned = true;
  55. }
  56. return enabled;
  57. }