diff options
author | Brad King <brad.king@kitware.com> | 2022-12-02 13:23:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-12-02 13:24:05 (GMT) |
commit | 399d62db8b5edfa7f0ee9ea4c913b33dedba107b (patch) | |
tree | ff67ecc75854e82098f5ed6ff45f7a1a2830c4ec | |
parent | 3c07549b51d34b155cbfe13599af20736cca789f (diff) | |
parent | 52c21cbbda3d3b920fa453213ce86830b66ebb32 (diff) | |
download | CMake-399d62db8b5edfa7f0ee9ea4c913b33dedba107b.zip CMake-399d62db8b5edfa7f0ee9ea4c913b33dedba107b.tar.gz CMake-399d62db8b5edfa7f0ee9ea4c913b33dedba107b.tar.bz2 |
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 <kwrobot@kitware.com>
Merge-request: !7972
28 files changed, 156 insertions, 46 deletions
diff --git a/.gitlab/ci/configure_linux_gcc_cxx_modules_ninja.cmake b/.gitlab/ci/configure_linux_gcc_cxx_modules_ninja.cmake index 2b04e89..110df76 100644 --- a/.gitlab/ci/configure_linux_gcc_cxx_modules_ninja.cmake +++ b/.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") diff --git a/.gitlab/ci/configure_linux_gcc_cxx_modules_ninja_multi.cmake b/.gitlab/ci/configure_linux_gcc_cxx_modules_ninja_multi.cmake index 2b04e89..110df76 100644 --- a/.gitlab/ci/configure_linux_gcc_cxx_modules_ninja_multi.cmake +++ b/.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") diff --git a/.gitlab/ci/configure_windows_msvc_cxx_modules_common.cmake b/.gitlab/ci/configure_windows_msvc_cxx_modules_common.cmake index 8570196..38dd729 100644 --- a/.gitlab/ci/configure_windows_msvc_cxx_modules_common.cmake +++ b/.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 "") diff --git a/.gitlab/ci/configure_windows_vs2022_x64.cmake b/.gitlab/ci/configure_windows_vs2022_x64.cmake index c7d41ea..1e0f584 100644 --- a/.gitlab/ci/configure_windows_vs2022_x64.cmake +++ b/.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") diff --git a/Help/dev/experimental.rst b/Help/dev/experimental.rst index 03eb076..794a686 100644 --- a/Help/dev/experimental.rst +++ b/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 ========================= diff --git a/Source/cmExperimental.cxx b/Source/cmExperimental.cxx index 922b53f..bbb5840 100644 --- a/Source/cmExperimental.cxx +++ b/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.", diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 1594457..6f6109e 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/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( diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index 2e573ec..4c69aeb 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/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, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index e06dc9b..ef4bcf8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/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"); diff --git a/Tests/RunCMake/CXXModules/CMakeLists.txt b/Tests/RunCMake/CXXModules/CMakeLists.txt index 708d92c..4611999 100644 --- a/Tests/RunCMake/CXXModules/CMakeLists.txt +++ b/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) diff --git a/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt b/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt index 52f781f..2bee19f 100644 --- a/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt +++ b/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 diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 81a086a..01d59f8 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/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) diff --git a/Tests/RunCMake/CXXModules/compiler_introspection.cmake b/Tests/RunCMake/CXXModules/compiler_introspection.cmake index 7a2df3d..0e61383 100644 --- a/Tests/RunCMake/CXXModules/compiler_introspection.cmake +++ b/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}") diff --git a/Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt b/Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt index 433b461..ac80356 100644 --- a/Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt +++ b/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)) diff --git a/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake b/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake index 381094e..9768543 100644 --- a/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake +++ b/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 diff --git a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt index b814b3b..20e4b2b 100644 --- a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt +++ b/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) diff --git a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt index db0484d..4fd9dca 100644 --- a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt +++ b/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) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt index 6145210..80f7c36 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt +++ b/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) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt index 6145210..80f7c36 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt +++ b/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) diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt b/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt index 7d79bad..2cb5957 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt +++ b/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. diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt index 551c55c..f2f1c38 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt +++ b/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) diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx index 27087d7..c3d449e 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx +++ b/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; diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx index 8184a40..4ba23a6 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx +++ b/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 diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx index 81e93f4..2c7ec3e 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx +++ b/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 diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx index ad1e04d..fe84261 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx +++ b/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; diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx index 8374110..b47510b 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx +++ b/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() diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake b/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake index 5ade637..1809505 100644 --- a/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake +++ b/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) diff --git a/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake b/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake index 332441c..064cacb 100644 --- a/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake +++ b/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) |