cmExperimental.cxx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. false },
  23. };
  24. static_assert(sizeof(LookupTable) / sizeof(LookupTable[0]) ==
  25. static_cast<size_t>(cmExperimental::Feature::Sentinel),
  26. "Experimental feature lookup table mismatch");
  27. cmExperimental::FeatureData& DataForFeature(cmExperimental::Feature f)
  28. {
  29. assert(f != cmExperimental::Feature::Sentinel);
  30. return LookupTable[static_cast<size_t>(f)];
  31. }
  32. }
  33. const cmExperimental::FeatureData& cmExperimental::DataForFeature(Feature f)
  34. {
  35. return ::DataForFeature(f);
  36. }
  37. bool cmExperimental::HasSupportEnabled(cmMakefile const& mf, Feature f)
  38. {
  39. bool enabled = false;
  40. auto& data = ::DataForFeature(f);
  41. auto value = mf.GetDefinition(data.Variable);
  42. if (value == data.Uuid) {
  43. enabled = true;
  44. }
  45. if (enabled && !data.Warned) {
  46. mf.IssueMessage(MessageType::AUTHOR_WARNING, data.Description);
  47. data.Warned = true;
  48. }
  49. return enabled;
  50. }