Browse Source

cmCxxModuleUsageEffects: add a class to capture module usage effects

When importing a C++ module, there may be requirements imposed by the
importer so that the compiler can reliably read the BMI. For example,
the standard used in the importer may need to also apply to the imported
BMI.

Right now, there are no tracked requirements. As we learn more, this
class can start tracking more information.

See: https://wg21.link/p2581r2
Ben Boeckel 2 years ago
parent
commit
cb356b540c
4 changed files with 46 additions and 0 deletions
  1. 2 0
      Source/CMakeLists.txt
  2. 21 0
      Source/cmCxxModuleUsageEffects.cxx
  3. 22 0
      Source/cmCxxModuleUsageEffects.h
  4. 1 0
      bootstrap

+ 2 - 0
Source/CMakeLists.txt

@@ -170,6 +170,8 @@ add_library(
   cmCustomCommandTypes.h
   cmCxxModuleMapper.cxx
   cmCxxModuleMapper.h
+  cmCxxModuleUsageEffects.cxx
+  cmCxxModuleUsageEffects.h
   cmDefinitions.cxx
   cmDefinitions.h
   cmDependencyProvider.h

+ 21 - 0
Source/cmCxxModuleUsageEffects.cxx

@@ -0,0 +1,21 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#include "cmCxxModuleUsageEffects.h"
+
+cmCxxModuleUsageEffects::cmCxxModuleUsageEffects(
+  cmGeneratorTarget const* /*gt*/)
+  : Hash("0000000000000000000000000000000000000000")
+{
+  // TODO: collect information from the generator target as to what might
+  // affect module consumption.
+}
+
+void cmCxxModuleUsageEffects::ApplyToTarget(cmTarget* /*tgt*/)
+{
+  // TODO: apply the information collected in the constructor
+}
+
+std::string const& cmCxxModuleUsageEffects::GetHash() const
+{
+  return this->Hash;
+}

+ 22 - 0
Source/cmCxxModuleUsageEffects.h

@@ -0,0 +1,22 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#pragma once
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+class cmGeneratorTarget;
+class cmTarget;
+
+class cmCxxModuleUsageEffects
+{
+public:
+  cmCxxModuleUsageEffects(cmGeneratorTarget const* gt);
+
+  void ApplyToTarget(cmTarget* tgt);
+  std::string const& GetHash() const;
+
+private:
+  std::string Hash;
+};

+ 1 - 0
bootstrap

@@ -333,6 +333,7 @@ CMAKE_CXX_SOURCES="\
   cmCustomCommandGenerator \
   cmCustomCommandLines \
   cmCxxModuleMapper \
+  cmCxxModuleUsageEffects \
   cmDefinePropertyCommand \
   cmDefinitions \
   cmDocumentationFormatter \