ソースを参照

Merge topic 'cxxmodules-vs'

52c21cbbda ci: enable C++20 module testing with the VS 2022 generator
2991e92ea7 cmExperimental: recycle C++20 module support UUID
82833fb3c0 Help/dev/experimental: document C++20 module limitations
388acfd46d Tests/RunCMake/CXXModules: add support for Visual Studio
069a32b03c Tests/RunCMake/CXXModules: split out collation-requiring tests
ef03a3a2f5 Tests/RunCMake/CXXModules: factor out generator support detection
736123464f Tests/RunCMake/CXXModules: update `NoDyndepSupport` for VS2019 and older
4a4ce031cd Tests/RunCMake/CXXModules: catch VS circular error message
...

Acked-by: Kitware Robot <[email protected]>
Merge-request: !7972
Brad King 2 年 前
コミット
399d62db8b
28 ファイル変更156 行追加46 行削除
  1. 1 1
      .gitlab/ci/configure_linux_gcc_cxx_modules_ninja.cmake
  2. 1 1
      .gitlab/ci/configure_linux_gcc_cxx_modules_ninja_multi.cmake
  3. 1 1
      .gitlab/ci/configure_windows_msvc_cxx_modules_common.cmake
  4. 3 0
      .gitlab/ci/configure_windows_vs2022_x64.cmake
  5. 26 1
      Help/dev/experimental.rst
  6. 1 1
      Source/cmExperimental.cxx
  7. 2 2
      Source/cmGlobalVisualStudio7Generator.h
  8. 10 0
      Source/cmGlobalVisualStudioVersionedGenerator.h
  9. 38 5
      Source/cmVisualStudio10TargetGenerator.cxx
  10. 1 1
      Tests/RunCMake/CXXModules/CMakeLists.txt
  11. 5 0
      Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt
  12. 20 4
      Tests/RunCMake/CXXModules/RunCMakeTest.cmake
  13. 1 0
      Tests/RunCMake/CXXModules/compiler_introspection.cmake
  14. 1 1
      Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt
  15. 1 1
      Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake
  16. 1 1
      Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt
  17. 1 1
      Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt
  18. 1 1
      Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt
  19. 1 1
      Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt
  20. 1 1
      Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt
  21. 7 0
      Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt
  22. 4 2
      Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx
  23. 9 7
      Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx
  24. 9 7
      Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx
  25. 4 2
      Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx
  26. 4 2
      Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx
  27. 1 1
      Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake
  28. 1 1
      Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake

+ 1 - 1
.gitlab/ci/configure_linux_gcc_cxx_modules_ninja.cmake

@@ -1,4 +1,4 @@
-set(CMake_TEST_MODULE_COMPILATION "named,partitions,internal_partitions,export_bmi,install_bmi" CACHE STRING "")
+set(CMake_TEST_MODULE_COMPILATION "named,collation,partitions,internal_partitions,export_bmi,install_bmi" CACHE STRING "")
 set(CMake_TEST_MODULE_COMPILATION_RULES "${CMAKE_CURRENT_LIST_DIR}/cxx_modules_rules_gcc.cmake" CACHE STRING "")
 
 include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")

+ 1 - 1
.gitlab/ci/configure_linux_gcc_cxx_modules_ninja_multi.cmake

@@ -1,4 +1,4 @@
-set(CMake_TEST_MODULE_COMPILATION "named,partitions,internal_partitions,export_bmi,install_bmi" CACHE STRING "")
+set(CMake_TEST_MODULE_COMPILATION "named,collation,partitions,internal_partitions,export_bmi,install_bmi" CACHE STRING "")
 set(CMake_TEST_MODULE_COMPILATION_RULES "${CMAKE_CURRENT_LIST_DIR}/cxx_modules_rules_gcc.cmake" CACHE STRING "")
 
 include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")

+ 1 - 1
.gitlab/ci/configure_windows_msvc_cxx_modules_common.cmake

@@ -1,2 +1,2 @@
-set(CMake_TEST_MODULE_COMPILATION "named,partitions,internal_partitions,shared,export_bmi,install_bmi" CACHE STRING "")
+set(CMake_TEST_MODULE_COMPILATION "named,collation,partitions,internal_partitions,shared,export_bmi,install_bmi" CACHE STRING "")
 set(CMake_TEST_MODULE_COMPILATION_RULES "${CMAKE_CURRENT_LIST_DIR}/cxx_modules_rules_msvc.cmake" CACHE STRING "")

+ 3 - 0
.gitlab/ci/configure_windows_vs2022_x64.cmake

@@ -1 +1,4 @@
+set(CMake_TEST_MODULE_COMPILATION "named,partitions" CACHE STRING "")
+
+include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_msvc_cxx_modules_common.cmake")
 include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_vs_common.cmake")

+ 26 - 1
Help/dev/experimental.rst

@@ -18,12 +18,37 @@ C++20 Module APIs
 =================
 
 Variable: ``CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API``
-Value: ``3c375311-a3c9-4396-a187-3227ef642046``
+Value: ``9629ab6c-6c0e-423f-bb9d-cc5ac4a22041``
 
 In order to support C++20 modules, there are a number of behaviors that have
 CMake APIs to provide the required features to build and export them from a
 project.
 
+Limitations
+-----------
+
+There are a number of known limitations of the current C++20 module support in
+CMake.  This does not document known limitations or bugs in compilers as these
+can change over time.
+
+For all generators:
+
+- Only in-project modules may be used.  While there is some support for
+  exporting module information, there is no mechanism for using it at the
+  moment.
+
+For the Ninja Generators:
+
+- ``ninja`` 1.10 or newer is required.
+
+For the Visual Studio Generators:
+
+- Only Visual Studio 2022 and toolchains newer than 19.34 (Visual Studio
+  17.4).
+- No support for exporting or installing BMI or module information.
+- No diagnosis of using modules provided by ``PRIVATE`` sources from
+  ``PUBLIC`` module sources.
+
 C++20 Module Dependencies
 =========================
 

+ 1 - 1
Source/cmExperimental.cxx

@@ -27,7 +27,7 @@ struct FeatureData
   bool Warned;
 } LookupTable[] = {
   // CxxModuleCMakeApi
-  { "3c375311-a3c9-4396-a187-3227ef642046",
+  { "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041",
     "CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API",
     "CMake's C++ module support is experimental. It is meant only for "
     "experimentation and feedback to CMake developers.",

+ 2 - 2
Source/cmGlobalVisualStudio7Generator.h

@@ -115,6 +115,8 @@ public:
 
   cmIDEFlagTable const* ExtraFlagTable;
 
+  virtual bool SupportsCxxModuleDyndep() const { return false; }
+
 protected:
   cmGlobalVisualStudio7Generator(cmake* cm,
                                  std::string const& platformInGeneratorName);
@@ -158,8 +160,6 @@ protected:
     cmValue typeGuid,
     const std::set<BT<std::pair<std::string, bool>>>& dependencies) = 0;
 
-  virtual bool SupportsCxxModuleDyndep() const { return false; }
-
   std::string ConvertToSolutionPath(const std::string& path);
 
   std::set<std::string> IsPartOfDefaultBuild(

+ 10 - 0
Source/cmGlobalVisualStudioVersionedGenerator.h

@@ -46,6 +46,16 @@ public:
 
   const char* GetAndroidApplicationTypeRevision() const override;
 
+  bool CheckCxxModuleSupport() override
+  {
+    this->CxxModuleSupportCheck();
+    return this->SupportsCxxModuleDyndep();
+  }
+  bool SupportsCxxModuleDyndep() const override
+  {
+    return this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS17;
+  }
+
 protected:
   cmGlobalVisualStudioVersionedGenerator(
     VSVersion version, cmake* cm, const std::string& name,

+ 38 - 5
Source/cmVisualStudio10TargetGenerator.cxx

@@ -356,7 +356,8 @@ void cmVisualStudio10TargetGenerator::Generate()
     this->GeneratorTarget->CheckCxxModuleStatus(config);
   }
 
-  if (this->GeneratorTarget->HaveCxx20ModuleSources()) {
+  if (this->GeneratorTarget->HaveCxx20ModuleSources() &&
+      !this->GlobalGenerator->SupportsCxxModuleDyndep()) {
     this->Makefile->IssueMessage(
       MessageType::FATAL_ERROR,
       cmStrCat("The \"", this->GeneratorTarget->GetName(),
@@ -2710,6 +2711,8 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
   }
 
   for (std::string const& config : this->Configurations) {
+    this->GeneratorTarget->NeedCxxModuleSupport(lang, config);
+
     std::string configUpper = cmSystemTools::UpperCase(config);
     std::string configDefines = defines;
     std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
@@ -2722,6 +2725,31 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
       configDefines += *ccdefs;
     }
 
+    bool const shouldScanForModules = lang == "CXX"_s &&
+      this->GeneratorTarget->NeedDyndepForSource(lang, config, source);
+    auto const* fs =
+      this->GeneratorTarget->GetFileSetForSource(config, source);
+    const char* compileAsPerConfig = compileAs;
+    if (fs &&
+        (fs->GetType() == "CXX_MODULES"_s ||
+         fs->GetType() == "CXX_MODULE_HEADER_UNITS"_s)) {
+      if (lang == "CXX"_s) {
+        if (fs->GetType() == "CXX_MODULES"_s) {
+          compileAsPerConfig = "CompileAsCppModule";
+        } else {
+          compileAsPerConfig = "CompileAsHeaderUnit";
+        }
+      } else {
+        this->Makefile->IssueMessage(
+          MessageType::FATAL_ERROR,
+          cmStrCat(
+            "Target \"", this->GeneratorTarget->Target->GetName(),
+            "\" contains the source\n  ", source->GetFullPath(),
+            "\nin a file set of type \"", fs->GetType(),
+            R"(" but the source is not classified as a "CXX" source.)"));
+      }
+    }
+
     // We have pch state in the following situation:
     // 1. We have SKIP_PRECOMPILE_HEADERS == true
     // 2. We are creating the pre-compiled header
@@ -2744,8 +2772,8 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     // if we have flags or defines for this config then
     // use them
     if (!flags.empty() || !options.empty() || !configDefines.empty() ||
-        !includes.empty() || compileAs || noWinRT || !options.empty() ||
-        needsPCHFlags) {
+        !includes.empty() || compileAsPerConfig || noWinRT ||
+        !options.empty() || needsPCHFlags) {
       cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
       cmIDEFlagTable const* flagtable = nullptr;
       const std::string& srclang = source->GetLanguage();
@@ -2770,8 +2798,13 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
       cmVS10GeneratorOptions clOptions(
         this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
         flagtable, this);
-      if (compileAs) {
-        clOptions.AddFlag("CompileAs", compileAs);
+      if (compileAsPerConfig) {
+        clOptions.AddFlag("CompileAs", compileAsPerConfig);
+      }
+      if (shouldScanForModules) {
+        clOptions.AddFlag("ScanSourceforModuleDependencies", "true");
+      } else {
+        clOptions.AddFlag("ScanSourceforModuleDependencies", "false");
       }
       if (noWinRT) {
         clOptions.AddFlag("CompileAsWinRT", "false");

+ 1 - 1
Tests/RunCMake/CXXModules/CMakeLists.txt

@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 3.23)
 project(${RunCMake_TEST} NONE)
 
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 include(${RunCMake_TEST}.cmake)

+ 5 - 0
Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt

@@ -22,6 +22,11 @@ CMake Error:
   by the generator
 
 (
+CMake Warning \(dev\):
+  C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is
+  experimental.  It is meant only for compiler developers to try.
+This warning is for project developers.  Use -Wno-dev to suppress it.
+)?(
 CMake Error in CMakeLists.txt:
   The "nodyndep" target contains C\+\+ module sources which are not supported
   by the generator

+ 20 - 4
Tests/RunCMake/CXXModules/RunCMakeTest.cmake

@@ -36,10 +36,20 @@ if (RunCMake_GENERATOR MATCHES "Ninja")
   endif ()
 endif ()
 
+set(generator_supports_cxx_modules 0)
+if (RunCMake_GENERATOR MATCHES "Ninja" AND
+    ninja_version VERSION_GREATER_EQUAL "1.10" AND
+    "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
+  set(generator_supports_cxx_modules 1)
+endif ()
+
+if (RunCMake_GENERATOR MATCHES "Visual Studio" AND
+    CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.34")
+  set(generator_supports_cxx_modules 1)
+endif ()
+
 # Test behavior when the generator does not support C++20 modules.
-if (NOT RunCMake_GENERATOR MATCHES "Ninja" OR
-    ninja_version VERSION_LESS "1.10" OR
-    NOT "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
+if (NOT generator_supports_cxx_modules)
   if ("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
     run_cmake(NoDyndepSupport)
   endif ()
@@ -79,6 +89,8 @@ if (RunCMake_GENERATOR MATCHES "Ninja")
   run_cmake(NinjaDependInfoFileSet)
   run_cmake(NinjaDependInfoExport)
   run_cmake(NinjaDependInfoBMIInstall)
+elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
+  # Not supported yet.
 else ()
   message(FATAL_ERROR
     "Please add 'DependInfo' tests for the '${RunCMake_GENERATOR}' generator.")
@@ -132,7 +144,6 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
   run_cxx_module_test(simple)
   run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
   run_cxx_module_test(generated)
-  run_cxx_module_test(public-req-private)
   run_cxx_module_test(deep-chain)
   run_cxx_module_test(duplicate)
   set(RunCMake_CXXModules_NO_TEST 1)
@@ -141,6 +152,11 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
   run_cxx_module_test(scan_properties)
 endif ()
 
+# Tests which require collation work.
+if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION)
+  run_cxx_module_test(public-req-private)
+endif ()
+
 # Tests which use named modules in shared libraries.
 if ("shared" IN_LIST CMake_TEST_MODULE_COMPILATION)
   run_cxx_module_test(library library-shared -DBUILD_SHARED_LIBS=ON)

+ 1 - 0
Tests/RunCMake/CXXModules/compiler_introspection.cmake

@@ -20,6 +20,7 @@ string(APPEND info "\
 set(CMAKE_CXX_COMPILE_FEATURES \"${CMAKE_CXX_COMPILE_FEATURES}\")
 set(CMAKE_MAKE_PROGRAM \"${CMAKE_MAKE_PROGRAM}\")
 set(forced_cxx_standard \"${forced_cxx_standard}\")
+set(CMAKE_CXX_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\")
 ")
 
 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}")

+ 1 - 1
Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt

@@ -1 +1 @@
-(Ninja generators)?(build stopped: dependency cycle:)
+((Ninja generators)?(build stopped: dependency cycle:)|(Visual Studio generators)?(error : Cannot build the following source files because there is a cyclic dependency between them))

+ 1 - 1
Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake

@@ -1,4 +1,4 @@
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 if (NOT EXISTS "${CMake_TEST_MODULE_COMPILATION_RULES}")
   message(FATAL_ERROR

+ 1 - 1
Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt

@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.24)
 project(cxx_modules_library NONE)
 
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 find_package(export_bmi_and_interfaces REQUIRED)
 

+ 1 - 1
Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt

@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.24)
 project(cxx_modules_library NONE)
 
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 find_package(export_bmi_and_interfaces REQUIRED)
 

+ 1 - 1
Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt

@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.24)
 project(cxx_modules_library NONE)
 
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 find_package(export_interfaces REQUIRED)
 

+ 1 - 1
Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt

@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.24)
 project(cxx_modules_library NONE)
 
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 find_package(export_interfaces REQUIRED)
 

+ 1 - 1
Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt

@@ -1,4 +1,4 @@
-CMake Warning \(dev\) at CMakeLists.txt:20 \(target_sources\):
+CMake Warning \(dev\) at CMakeLists.txt:25 \(target_sources\):
   CMake's C\+\+ module support is experimental.  It is meant only for
   experimentation and feedback to CMake developers.
 This warning is for project developers.  Use -Wno-dev to suppress it.

+ 7 - 0
Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt

@@ -3,6 +3,11 @@ project(scan_properties CXX)
 
 include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
 
+set(scanning_control 1)
+if (CMAKE_GENERATOR MATCHES "Visual Studio")
+  set(scanning_control 0)
+endif ()
+
 # To detect that not-to-be scanned sources are not scanned, add a `-D` to the
 # scan flags so that the files can detect whether scanning happened and error
 # if not.
@@ -31,6 +36,7 @@ target_sources(scans_everything
         module.cxx)
 target_compile_features(scans_everything PRIVATE cxx_std_20)
 target_compile_definitions(scans_everything PRIVATE SCAN_AT_TARGET_LEVEL=1)
+target_compile_definitions(scans_everything PRIVATE "SCANNING_CONTROL=${scanning_control}")
 
 set(CMAKE_CXX_SCAN_FOR_MODULES 0)
 
@@ -49,6 +55,7 @@ target_sources(no_scan_everything
         module.cxx)
 target_compile_features(no_scan_everything PRIVATE cxx_std_20)
 target_compile_definitions(no_scan_everything PRIVATE SCAN_AT_TARGET_LEVEL=0)
+target_compile_definitions(no_scan_everything PRIVATE "SCANNING_CONTROL=${scanning_control}")
 
 add_test(NAME scanned COMMAND scans_everything)
 add_test(NAME unscanned COMMAND no_scan_everything)

+ 4 - 2
Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx

@@ -1,5 +1,7 @@
-#ifndef CMAKE_SCANNED_THIS_SOURCE
-#  error "This file should have been scanned"
+#if SCANNING_CONTROL
+#  ifndef CMAKE_SCANNED_THIS_SOURCE
+#    error "This file should have been scanned"
+#  endif
 #endif
 
 import M;

+ 9 - 7
Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx

@@ -1,10 +1,12 @@
-#if SCAN_AT_TARGET_LEVEL
-#  ifndef CMAKE_SCANNED_THIS_SOURCE
-#    error "This file should have been scanned"
-#  endif
-#else
-#  ifdef CMAKE_SCANNED_THIS_SOURCE
-#    error "This file should not have been scanned"
+#if SCANNING_CONTROL
+#  if SCAN_AT_TARGET_LEVEL
+#    ifndef CMAKE_SCANNED_THIS_SOURCE
+#      error "This file should have been scanned"
+#    endif
+#  else
+#    ifdef CMAKE_SCANNED_THIS_SOURCE
+#      error "This file should not have been scanned"
+#    endif
 #  endif
 #endif
 

+ 9 - 7
Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx

@@ -1,10 +1,12 @@
-#if SCAN_AT_TARGET_LEVEL
-#  ifndef CMAKE_SCANNED_THIS_SOURCE
-#    error "This file should have been scanned"
-#  endif
-#else
-#  ifdef CMAKE_SCANNED_THIS_SOURCE
-#    error "This file should not have been scanned"
+#if SCANNING_CONTROL
+#  if SCAN_AT_TARGET_LEVEL
+#    ifndef CMAKE_SCANNED_THIS_SOURCE
+#      error "This file should have been scanned"
+#    endif
+#  else
+#    ifdef CMAKE_SCANNED_THIS_SOURCE
+#      error "This file should not have been scanned"
+#    endif
 #  endif
 #endif
 

+ 4 - 2
Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx

@@ -1,5 +1,7 @@
-#ifndef CMAKE_SCANNED_THIS_SOURCE
-#  error "This file should have been scanned"
+#if SCANNING_CONTROL
+#  ifndef CMAKE_SCANNED_THIS_SOURCE
+#    error "This file should have been scanned"
+#  endif
 #endif
 
 export module M;

+ 4 - 2
Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx

@@ -1,5 +1,7 @@
-#ifdef CMAKE_SCANNED_THIS_SOURCE
-#  error "This file should not have been scanned"
+#if SCANNING_CONTROL
+#  ifdef CMAKE_SCANNED_THIS_SOURCE
+#    error "This file should not have been scanned"
+#  endif
 #endif
 
 int never_scan()

+ 1 - 1
Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake

@@ -1,6 +1,6 @@
 enable_language(C)
 
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 add_library(lib1 STATIC empty.c)
 target_sources(lib1 PRIVATE FILE_SET UNKNOWN)

+ 1 - 1
Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake

@@ -1,6 +1,6 @@
 enable_language(C)
 
-set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041")
 
 add_library(lib1 STATIC empty.c)
 target_sources(lib1 PRIVATE FILE_SET a TYPE UNKNOWN)