From ab1bd6f6c624cc55bbd826022ad88ec94b355de2 Mon Sep 17 00:00:00 2001 From: Vito Gamberini Date: Tue, 28 Jul 2026 19:40:53 -0400 Subject: [PATCH] c++modules: Remove CXX_MODULE_STD and CMAKE_CXX_COMPILER_IMPORT_STD Fixes: #27966, #27992, #28000 --- Help/dev/experimental.rst | 8 +- Help/manual/cmake-cxxmodules.7.rst | 13 +- Help/prop_tgt/CXX_MODULE_STD.rst | 5 + .../CMAKE_CXX_COMPILER_IMPORT_STD.rst | 6 + Help/variable/CMAKE_CXX_MODULE_STD.rst | 5 + Modules/CMakeCXXCompiler.cmake.in | 1 - Modules/CMakeDetermineCompilerSupport.cmake | 11 -- Source/cmCacheDocumentationTable.cxx | 2 - Source/cmCommonTargetGenerator.cxx | 46 ++++-- Source/cmExperimental.cxx | 2 +- Source/cmExportFileGenerator.cxx | 8 - Source/cmGeneratorTarget.cxx | 141 +++++++----------- Source/cmGeneratorTarget.h | 1 + Source/cmGlobalGenerator.cxx | 71 +++++++-- Source/cmGlobalGenerator.h | 1 + Source/cmGlobalNinjaGenerator.cxx | 98 +++++++++--- Source/cmGlobalNinjaGenerator.h | 4 + Source/cmTarget.cxx | 2 - .../CXXModules/CXXImportStdConfig-result.txt | 1 - .../CXXModules/CXXImportStdConfig-stderr.txt | 3 - .../CXXModules/CXXImportStdConfig.cmake | 10 -- .../CXXImportStdHeadTarget-result.txt | 1 - .../CXXImportStdHeadTarget-stderr.txt | 9 -- .../CXXModules/CXXImportStdHeadTarget.cmake | 10 -- .../CXXModules/CXXImportStdInvalidGenex.cmake | 11 -- .../CXXImportStdLinkLanguage-result.txt | 1 - .../CXXImportStdLinkLanguage-stderr.txt | 7 - .../CXXModules/CXXImportStdLinkLanguage.cmake | 10 -- Tests/RunCMake/CXXModules/Inspect.cmake | 2 - .../CXXModules/NoCXX23TargetNotRequired.cmake | 11 -- .../NoCXX23TargetRequired-result.txt | 1 - .../NoCXX23TargetRequired-stderr.txt | 8 - .../CXXModules/NoCXX23TargetRequired.cmake | 11 -- .../CXXModules/NoCXX23TargetUnset.cmake | 13 -- .../CXXModules/NoCXX26TargetNotRequired.cmake | 11 -- .../NoCXX26TargetRequired-result.txt | 1 - .../NoCXX26TargetRequired-stderr.txt | 8 - .../CXXModules/NoCXX26TargetRequired.cmake | 11 -- .../CXXModules/NoCXX26TargetUnset.cmake | 13 -- Tests/RunCMake/CXXModules/RunCMakeTest.cmake | 21 --- .../CXXModulesCompile/RunCMakeTest.cmake | 9 +- .../imp-dummy-std/CMakeLists.txt | 4 +- .../imp-std-exp-no-std-build/CMakeLists.txt | 9 +- .../test/CMakeLists.txt | 29 ++-- .../imp-std-exp-no-std-install/CMakeLists.txt | 11 +- .../test/CMakeLists.txt | 29 ++-- ...t => imp-std-no-std-json-build-result.txt} | 0 .../imp-std-no-std-json-build-stdout.txt | 1 + ...err.txt => imp-std-no-std-json-stderr.txt} | 0 .../CMakeLists.txt | 8 +- .../imp-std-no-std-json/main.cxx | 5 + .../imp-std-no-std-prop-build-stdout.txt | 1 - .../imp-std-no-std-prop/main.cxx | 6 - .../imp-std-not-in-exp-build/CMakeLists.txt | 8 +- .../test/CMakeLists.txt | 31 ++-- .../imp-std-not-in-exp-install/CMakeLists.txt | 10 +- .../test/CMakeLists.txt | 29 ++-- .../imp-std-shared-stderr.txt | 9 ++ .../imp-std-shared/CMakeLists.txt | 54 +++++++ .../CXXModulesCompile/imp-std-shared/main.cxx | 7 + .../imp-std-shared/test/CMakeLists.txt | 15 ++ .../imp-std-shared/test/main.cxx | 7 + .../imp-std-shared/uses-std.cxx | 16 ++ .../imp-std-trans/CMakeLists.txt | 10 +- .../CXXModulesCompile/imp-std/CMakeLists.txt | 4 +- .../codemodel-v2-import-std/CMakeLists.txt | 4 +- .../ToolchainSkipsChecks/CXX-toolchain.cmake | 2 - .../Experimental/CxxImportStd-quiet.cmake | 2 +- .../Experimental/CxxImportStd-set.cmake | 2 +- .../property_init/CompileSources.cmake | 9 -- 70 files changed, 497 insertions(+), 433 deletions(-) delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdConfig-result.txt delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdConfig-stderr.txt delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdConfig.cmake delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-result.txt delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-stderr.txt delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdHeadTarget.cmake delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdInvalidGenex.cmake delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdLinkLanguage-result.txt delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdLinkLanguage-stderr.txt delete mode 100644 Tests/RunCMake/CXXModules/CXXImportStdLinkLanguage.cmake delete mode 100644 Tests/RunCMake/CXXModules/NoCXX23TargetNotRequired.cmake delete mode 100644 Tests/RunCMake/CXXModules/NoCXX23TargetRequired-result.txt delete mode 100644 Tests/RunCMake/CXXModules/NoCXX23TargetRequired-stderr.txt delete mode 100644 Tests/RunCMake/CXXModules/NoCXX23TargetRequired.cmake delete mode 100644 Tests/RunCMake/CXXModules/NoCXX23TargetUnset.cmake delete mode 100644 Tests/RunCMake/CXXModules/NoCXX26TargetNotRequired.cmake delete mode 100644 Tests/RunCMake/CXXModules/NoCXX26TargetRequired-result.txt delete mode 100644 Tests/RunCMake/CXXModules/NoCXX26TargetRequired-stderr.txt delete mode 100644 Tests/RunCMake/CXXModules/NoCXX26TargetRequired.cmake delete mode 100644 Tests/RunCMake/CXXModules/NoCXX26TargetUnset.cmake rename Tests/RunCMake/CXXModulesCompile/{imp-std-no-std-prop-build-result.txt => imp-std-no-std-json-build-result.txt} (100%) create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-build-stdout.txt rename Tests/RunCMake/CXXModulesCompile/{imp-std-no-std-prop-stderr.txt => imp-std-no-std-json-stderr.txt} (100%) rename Tests/RunCMake/CXXModulesCompile/{imp-std-no-std-prop => imp-std-no-std-json}/CMakeLists.txt (63%) create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json/main.cxx delete mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-build-stdout.txt delete mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop/main.cxx create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-shared-stderr.txt create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-shared/CMakeLists.txt create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-shared/main.cxx create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/CMakeLists.txt create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/main.cxx create mode 100644 Tests/RunCMake/CXXModulesCompile/imp-std-shared/uses-std.cxx diff --git a/Help/dev/experimental.rst b/Help/dev/experimental.rst index e4e345ada4..d4639e9e6d 100644 --- a/Help/dev/experimental.rst +++ b/Help/dev/experimental.rst @@ -66,7 +66,7 @@ In order to activate support for ``import std`` in C++23 and newer targets, set * variable ``CMAKE_EXPERIMENTAL_CXX_IMPORT_STD`` to -* value ``f35a9ac6-8463-4d38-8eec-5d6008153e7d``. +* value ``25d6f6aa-be65-4692-b44e-87b23e96d4e1``. This UUID may change in future versions of CMake. Be sure to use the value documented here by the source tree of the version of CMake with which you are @@ -75,11 +75,7 @@ CMake, usually as part of a ``project()`` call. When activated, this experimental feature provides the following: -* The ``CXX_MODULE_STD`` target property and its initializing variable - ``CMAKE_CXX_MODULE_STD``. - -* Targets with the property set to a true value and at least ``cxx_std_23`` - may use ``import std;`` in any scanned C++ source file. +* Targets may use ``import std;`` in any scanned C++ source file. Build database support ====================== diff --git a/Help/manual/cmake-cxxmodules.7.rst b/Help/manual/cmake-cxxmodules.7.rst index fe150400ce..c086782917 100644 --- a/Help/manual/cmake-cxxmodules.7.rst +++ b/Help/manual/cmake-cxxmodules.7.rst @@ -91,7 +91,8 @@ library combinations: * Clang 18.1.2 and newer with standard library ``libc++`` or ``libstdc++`` * MSVC toolset 14.36 and newer (provided with Visual Studio 17.6 and newer) -* GCC 15 and newer +* GCC 15 and newer, with the exception of MacOS +* GCC 16 and newer on MacOS .. note:: @@ -100,12 +101,12 @@ library combinations: .. _`Ubuntu issue 2141579`: https://bugs.launchpad.net/ubuntu/+source/gcc-15/+bug/2141579 -The :variable:`CMAKE_CXX_COMPILER_IMPORT_STD` variable lists standard levels -which have support for ``import std`` in the active C++ toolchain. +Only the :ref:`Ninja Generators` currently support ``import std`` because +:ref:`Visual Studio Generators` do not support building :term:`BMIs ` +for ``IMPORTED`` targets. -Additionally, only the :ref:`Ninja Generators` currently support -``import std`` at this time because :ref:`Visual Studio Generators` do not -support building :term:`BMIs ` for ``IMPORTED`` targets. +``import std`` is available for all language standards which support C++ module +scanning (ie, C++20 and newer). .. note:: diff --git a/Help/prop_tgt/CXX_MODULE_STD.rst b/Help/prop_tgt/CXX_MODULE_STD.rst index 3c9bb2311e..ed65b6d59f 100644 --- a/Help/prop_tgt/CXX_MODULE_STD.rst +++ b/Help/prop_tgt/CXX_MODULE_STD.rst @@ -1,6 +1,11 @@ CXX_MODULE_STD -------------- +.. versionchanged:: 4.5 + + ``CXX_MODULE_STD`` no longer has any effect. ``import std;`` is handled + automatically on all sources with :prop_tgt:`CXX_SCAN_FOR_MODULES` enabled. + .. versionadded:: 3.30 ``CXX_MODULE_STD`` is a boolean specifying whether the target may use diff --git a/Help/variable/CMAKE_CXX_COMPILER_IMPORT_STD.rst b/Help/variable/CMAKE_CXX_COMPILER_IMPORT_STD.rst index 6605f1a094..a51e6f4d39 100644 --- a/Help/variable/CMAKE_CXX_COMPILER_IMPORT_STD.rst +++ b/Help/variable/CMAKE_CXX_COMPILER_IMPORT_STD.rst @@ -1,6 +1,12 @@ CMAKE_CXX_COMPILER_IMPORT_STD ----------------------------- +.. versionchanged:: 4.5 + + Reporting of supported C++ standard levels has been removed as toolchains + no longer control generation of standard library targets. + ``CMAKE_CXX_COMPILER_IMPORT_STD`` is left undefined. + .. versionadded:: 3.30 A list of C++ standard levels for which ``import std`` support exists for the diff --git a/Help/variable/CMAKE_CXX_MODULE_STD.rst b/Help/variable/CMAKE_CXX_MODULE_STD.rst index 057272bbe5..1f62881018 100644 --- a/Help/variable/CMAKE_CXX_MODULE_STD.rst +++ b/Help/variable/CMAKE_CXX_MODULE_STD.rst @@ -1,6 +1,11 @@ CMAKE_CXX_MODULE_STD -------------------- +.. versionchanged:: 4.5 + + ``CMAKE_CXX_MODULE_STD`` no longer has any effect. ``import std;`` is handled + automatically on all sources with :prop_tgt:`CXX_SCAN_FOR_MODULES` enabled. + .. versionadded:: 3.30 Whether to add utility targets as dependencies to targets with at least diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 52495f46f4..03b0feb55d 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -98,6 +98,5 @@ set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_CXX_COMPILER_CLANG_RESOURCE_DIR "@CMAKE_CXX_COMPILER_CLANG_RESOURCE_DIR@") -set(CMAKE_CXX_COMPILER_IMPORT_STD "@CMAKE_CXX_COMPILER_IMPORT_STD@") set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "@CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE@") set(CMAKE_CXX_STDLIB_MODULES_JSON "@CMAKE_CXX_STDLIB_MODULES_JSON@") diff --git a/Modules/CMakeDetermineCompilerSupport.cmake b/Modules/CMakeDetermineCompilerSupport.cmake index ed80ba7e38..eec765dc3d 100644 --- a/Modules/CMakeDetermineCompilerSupport.cmake +++ b/Modules/CMakeDetermineCompilerSupport.cmake @@ -152,19 +152,8 @@ function(cmake_determine_compiler_support lang) endif() endif () - # Find the module metadata for import std - set(CMAKE_CXX_COMPILER_IMPORT_STD "") cmake_cxx_find_modules_json() - foreach(_cmake_import_std_version IN ITEMS 23 26) - if(CMAKE_CXX${_cmake_import_std_version}_COMPILE_FEATURES) - # Modules JSON covers all versions, otherwise rely on toolchain targets - if(CMAKE_CXX_STDLIB_MODULES_JSON) - list(APPEND CMAKE_CXX_COMPILER_IMPORT_STD ${_cmake_import_std_version}) - endif() - endif() - endforeach() - set(CMAKE_CXX_COMPILER_IMPORT_STD ${CMAKE_CXX_COMPILER_IMPORT_STD} PARENT_SCOPE) set(CMAKE_CXX_STDLIB_MODULES_JSON ${CMAKE_CXX_STDLIB_MODULES_JSON} PARENT_SCOPE) set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "${CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE}" PARENT_SCOPE) diff --git a/Source/cmCacheDocumentationTable.cxx b/Source/cmCacheDocumentationTable.cxx index 186ffeebd2..210e25dc8a 100644 --- a/Source/cmCacheDocumentationTable.cxx +++ b/Source/cmCacheDocumentationTable.cxx @@ -215,8 +215,6 @@ Entry const kEntries[] = { "Default value for CUDA_STANDARD_REQUIRED target property if set when a target is created. See the cmake-compile-features(7) manual for information on compile features and a list of supported compilers."_s }, { "CMAKE_CXX_EXTENSIONS"_s, "Default value for CXX_EXTENSIONS target property if set when a target is created. See the cmake-compile-features(7) manual for information on compile features and a list of supported compilers."_s }, - { "CMAKE_CXX_MODULE_STD"_s, - "Whether to add utility targets as dependencies for C++23 targets"_s }, { "CMAKE_CXX_SCAN_FOR_MODULES"_s, "Whether to scan C++ source files for module dependencies"_s }, { "CMAKE_CXX_STANDARD"_s, diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 41464bd16d..b1ccdb816e 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -31,6 +31,38 @@ #include "cmTargetTypes.h" #include "cmValue.h" +namespace { +bool LinkedTargetHasModules(cmGeneratorTarget const* target, + std::string const& lang, std::string const& config, + cmGlobalCommonGenerator const* gg, + cmGeneratorTarget const* currentTarget) +{ + if (!target) { + return false; + } + if (lang == "CXX"_s && target->HasCxxImportModuleErrors()) { + return true; + } + if (target->IsImported()) { + return false; + } + if (!gg->TargetOrderIndexLess(target, currentTarget)) { + return false; + } + if (target->GetType() == cm::TargetType::INTERFACE_LIBRARY && + !target->IsSynthetic()) { + return false; + } + if (lang == "CXX"_s && target->HaveCxx20ModuleSources()) { + return true; + } + if (lang == "Fortran"_s && target->HaveFortranSources(config)) { + return true; + } + return false; +} +} + cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) : GeneratorTarget(gt) , Makefile(gt->Makefile) @@ -252,18 +284,8 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories( } if (mappedLinkee && - !mappedLinkee->IsImported() - // Skip targets that build after this one in a static lib cycle. - && gg->TargetOrderIndexLess(mappedLinkee, this->GeneratorTarget) - // We can ignore the INTERFACE_LIBRARY items because - // Target->GetLinkInformation already processed their - // link interface and they don't have any output themselves. - && (mappedLinkee->GetType() != cm::TargetType::INTERFACE_LIBRARY - // Synthesized targets may have relevant rules. - || mappedLinkee->IsSynthetic()) && - ((lang == "CXX"_s && mappedLinkee->HaveCxx20ModuleSources()) || - (lang == "Fortran"_s && - mappedLinkee->HaveFortranSources(config)))) { + LinkedTargetHasModules(mappedLinkee, lang, config, gg, + this->GeneratorTarget)) { cmLocalGenerator* lg = mappedLinkee->GetLocalGenerator(); std::string di = mappedLinkee->GetSupportDirectory(); if (lg->GetGlobalGenerator()->IsMultiConfig()) { diff --git a/Source/cmExperimental.cxx b/Source/cmExperimental.cxx index ef9b893fdd..ada458e527 100644 --- a/Source/cmExperimental.cxx +++ b/Source/cmExperimental.cxx @@ -31,7 +31,7 @@ cmExperimental::FeatureData const LookupTable[] = { cmExperimental::TryCompileCondition::Always }, // CxxImportStd { "CxxImportStd", - "f35a9ac6-8463-4d38-8eec-5d6008153e7d", + "25d6f6aa-be65-4692-b44e-87b23e96d4e1", "CMAKE_EXPERIMENTAL_CXX_IMPORT_STD", "CMake's support for `import std;` in C++23 and newer is experimental. It " "is meant only for experimentation and feedback to CMake developers.", diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index fbedbff36f..0e00657faa 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -753,14 +753,6 @@ bool cmExportFileGenerator::PopulateCxxModuleExportProperties( ModuleTargetPropertyTable const exportedDirectModuleProperties[] = { { "CXX_EXTENSIONS"_s, ExportWhen::Defined }, - // Always define this property as it is an intrinsic property of the target - // and should not be inherited from the in-scope `CMAKE_CXX_MODULE_STD` - // variable. - // - // TODO(cxxmodules): A future policy may make this "ON" based on the target - // policies if unset. Add a new `ExportWhen` condition to handle it when - // this happens. - { "CXX_MODULE_STD"_s, ExportWhen::Always }, }; for (auto const& prop : exportedDirectModuleProperties) { auto const propNameStr = std::string(prop.Name); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0406de3c22..1728fb5984 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5332,7 +5332,6 @@ bool cmGeneratorTarget::IsNullImpliedByLinkLibraries( namespace { bool CreateCxxStdlibTarget(cmMakefile* makefile, cmLocalGenerator* lg, - std::string const& targetName, std::vector const& configs) { #ifndef CMAKE_BOOTSTRAP @@ -5344,25 +5343,33 @@ bool CreateCxxStdlibTarget(cmMakefile* makefile, cmLocalGenerator* lg, auto errorMessage = makefile->GetDefinition("CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE"); if (!errorMessage.IsEmpty()) { - makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat(R"(The "CXX_MODULE_STD" property on target ")", targetName, - "\" requires toolchain support, but it was not provided. " - "Reason:\n ", - *errorMessage)); - return false; + auto* stdlibTgt = makefile->AddImportedTarget( + "@cmake_cxx_std", cm::TargetType::INTERFACE_LIBRARY, + cm::ImportedTargetScope::Global); + stdlibTgt->SetProperty("CXX_IMPORT_ERROR_MESSAGE", *errorMessage); + stdlibTgt->SetProperty("CXX_IMPORT_ERROR_MODULES", "std;std.compat"); + + auto gt = cm::make_unique(stdlibTgt, lg); + lg->AddImportedGeneratorTarget(gt.get()); + lg->AddOwnedImportedGeneratorTarget(std::move(gt)); + return true; } auto metadataPath = makefile->GetDefinition("CMAKE_CXX_STDLIB_MODULES_JSON"); if (metadataPath.IsEmpty()) { - makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat( - R"("The "CXX_MODULE_STD" property on target ")", targetName, - "\" requires CMAKE_CXX_STDLIB_MODULES_JSON be set, but it was not " - "provided by the toolchain.")); - return false; + auto* stdlibTgt = makefile->AddImportedTarget( + "@cmake_cxx_std", cm::TargetType::INTERFACE_LIBRARY, + cm::ImportedTargetScope::Global); + stdlibTgt->SetProperty( + "CXX_IMPORT_ERROR_MESSAGE", + R"(CMAKE_CXX_STDLIB_MODULES_JSON set to empty string)"); + stdlibTgt->SetProperty("CXX_IMPORT_ERROR_MODULES", "std;std.compat"); + + auto gt = cm::make_unique(stdlibTgt, lg); + lg->AddImportedGeneratorTarget(gt.get()); + lg->AddOwnedImportedGeneratorTarget(std::move(gt)); + return true; } auto parseResult = cmCxxModuleMetadata::LoadFromFile(*metadataPath); @@ -5380,7 +5387,7 @@ bool CreateCxxStdlibTarget(cmMakefile* makefile, cmLocalGenerator* lg, auto* stdlibTgt = makefile->AddImportedTarget( "@cmake_cxx_std", cm::TargetType::INTERFACE_LIBRARY, - cm::ImportedTargetScope::Local); + cm::ImportedTargetScope::Global); cmCxxModuleMetadata::PopulateTarget(*stdlibTgt, *metadata, configs); cmStandardLevelResolver standardResolver(makefile); standardResolver.AddRequiredTargetFeature(stdlibTgt, "cxx_std_20"); @@ -5405,66 +5412,26 @@ bool CreateCxxStdlibTarget(cmMakefile* makefile, cmLocalGenerator* lg, bool cmGeneratorTarget::ApplyCXXStdTarget() { - std::vector const& configs = - this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); - auto std_prop = this->GetProperty("CXX_MODULE_STD"); - if (!std_prop) { - // TODO(cxxmodules): Add a target policy to flip the default here. Set - // `std_prop` based on it. + if (!cmExperimental::HasSupportEnabled( + *this->Makefile, cmExperimental::Feature::CxxImportStd)) { return true; } - std::string std_prop_value; - if (std_prop) { - // Evaluate generator expressions. - cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance()); - auto cge = ge.Parse(*std_prop); - if (!cge) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")", - this->GetName(), "\" is not a valid generator expression.")); - return false; - } - // But do not allow context-sensitive queries. Whether a target uses - // `import std` should not depend on configuration or properties of the - // consumer (head target). The link language also shouldn't matter, so ban - // it as well. - if (cge->GetHadHeadSensitiveCondition()) { - // Not reachable; all target-sensitive genexes actually fail to parse. - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")", - this->GetName(), - "\" contains a condition that queries the " - "consuming target which is not supported.")); - return false; - } - if (cge->GetHadLinkLanguageSensitiveCondition()) { - // Not reachable; all link language genexes actually fail to parse. - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")", - this->GetName(), - "\" contains a condition that queries the " - "link language which is not supported.")); - return false; - } - std_prop_value = cge->Evaluate(this->LocalGenerator, ""); - if (cge->GetHadContextSensitiveCondition()) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")", - this->GetName(), - "\" contains a context-sensitive condition " - "that is not supported.")); - return false; + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + + bool needsStd = false; + if (this->Target->IsImported()) { + needsStd = this->HaveInterfaceCxx20ModuleSources(); + } else { + for (auto const& config : configs) { + if (this->NeedCxxDyndep(config) == CxxModuleSupport::Enabled) { + needsStd = true; + break; + } } } - auto use_std = cmIsOn(std_prop_value); - - // If we have a value and it is not true, there's nothing to do. - if (std_prop && !use_std) { + if (!needsStd) { return true; } @@ -5472,29 +5439,26 @@ bool cmGeneratorTarget::ApplyCXXStdTarget() // already exist. BMI compatibility handles per-consumer standard level // differences by creating synthetic targets as needed. if (!this->Makefile->FindTargetToUse("@cmake_cxx_std") && - !CreateCxxStdlibTarget(this->Makefile, this->LocalGenerator, - this->GetName(), configs)) { + !CreateCxxStdlibTarget(this->Makefile, this->LocalGenerator, configs)) { return false; } - this->Target->AppendProperty("LINK_LIBRARIES", - "$"); - - // Check the experimental feature here. A toolchain may have - // skipped the check in the toolchain preparation logic. - if (!cmExperimental::HasSupportEnabled( - *this->Makefile, cmExperimental::Feature::CxxImportStd)) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "Experimental `import std` support not enabled when detecting " - "toolchain; it must be set before `CXX` is enabled (usually a " - "`project()` call)."); - return false; + if (this->Target->IsImported()) { + this->Target->AppendProperty("IMPORTED_CXX_MODULES_LINK_LIBRARIES", + "@cmake_cxx_std"); + } else { + this->Target->AppendProperty("LINK_LIBRARIES", + "$"); } return true; } +bool cmGeneratorTarget::HasCxxImportModuleErrors() const +{ + return this->Target->GetProperty("CXX_IMPORT_ERROR_MODULES") != nullptr; +} + cmCxxModuleUsageEffects const& cmGeneratorTarget::GetCxxModuleUsageEffects( std::string const& config) const { @@ -5602,11 +5566,6 @@ cmGeneratorTarget const* cmGeneratorTarget::GetCxxSyntheticTarget( for (auto const& innerConfig : allConfigs) { gtp->ComputeCompileFeatures(innerConfig); } - // See `cmGlobalGenerator::ApplyCXXStdTarget` in - // `cmGlobalGenerator::Compute` for non-synthetic target resolutions. - if (!gtp->ApplyCXXStdTarget()) { - return nullptr; - } lg->AddGeneratorTarget(std::move(gtp)); this->SynthCxxTargets[usageHash] = syntheticTarget; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ab84056a6..2e7497d31b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -1148,6 +1148,7 @@ public: std::string GetImportedXcFrameworkPath(std::string const& config) const; bool ApplyCXXStdTarget(); + bool HasCxxImportModuleErrors() const; cmCxxModuleUsageEffects const& GetCxxModuleUsageEffects( std::string const& config) const; cmGeneratorTarget const* GetTargetForCxxModules( diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 880fd3270a..5b8c0d7537 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1701,6 +1701,9 @@ bool cmGlobalGenerator::Compute() return false; } + // Write pre-generated module info for targets that report import errors. + this->WriteCxxImportErrorModules(); + // Iterate through all targets and set up C++20 module targets. // Create target templates for each imported target with C++20 modules. // INTERFACE library with BMI-generating rules and a collation step? @@ -2018,17 +2021,29 @@ void cmGlobalGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt, bool cmGlobalGenerator::ApplyCXXStdTarget() { for (auto const& gen : this->LocalGenerators) { - - // tgt->ApplyCXXStdTarget can create a target itself, so we need iterators - // which won't be invalidated by that target creation - auto const& genTgts = gen->GetGeneratorTargets(); - std::vector existingTgts; - existingTgts.reserve(genTgts.size()); - for (auto const& tgt : genTgts) { - existingTgts.push_back(tgt.get()); + // @cmake_cxx_std is added to OwnedImportedGeneratorTargets during + // iteration. If it doesn't exist yet, copy the list to protect against + // invalidation when CreateCxxStdlibTarget adds it. + if (gen->GetMakefile()->FindTargetToUse("@cmake_cxx_std")) { + for (auto const& tgt : gen->GetOwnedImportedGeneratorTargets()) { + if (!tgt->ApplyCXXStdTarget()) { + return false; + } + } + } else { + std::vector impTgts; + impTgts.reserve(gen->GetOwnedImportedGeneratorTargets().size()); + for (auto const& tgt : gen->GetOwnedImportedGeneratorTargets()) { + impTgts.push_back(tgt.get()); + } + for (auto* tgt : impTgts) { + if (!tgt->ApplyCXXStdTarget()) { + return false; + } + } } - for (auto const& tgt : existingTgts) { + for (auto const& tgt : gen->GetGeneratorTargets()) { if (!tgt->ApplyCXXStdTarget()) { return false; } @@ -2038,6 +2053,44 @@ bool cmGlobalGenerator::ApplyCXXStdTarget() return true; } +void cmGlobalGenerator::WriteCxxImportErrorModules() +{ +#ifndef CMAKE_BOOTSTRAP + for (auto const& gen : this->LocalGenerators) { + for (auto const& tgt : gen->GetOwnedImportedGeneratorTargets()) { + auto errorMsg = tgt->Target->GetProperty("CXX_IMPORT_ERROR_MESSAGE"); + auto modules = tgt->Target->GetProperty("CXX_IMPORT_ERROR_MODULES"); + if (!errorMsg || !modules) { + continue; + } + auto configs = + tgt->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + for (auto const& config : configs) { + auto dir = tgt->GetSupportDirectory(); + if (this->IsMultiConfig()) { + dir = cmStrCat(dir, '/', config); + } + cmSystemTools::MakeDirectory(dir); + + Json::Value moduleInfo(Json::objectValue); + moduleInfo["modules"] = Json::objectValue; + Json::Value importError(Json::objectValue); + importError["message"] = *errorMsg; + Json::Value modulesArray(Json::arrayValue); + for (auto const& m : cmList{ *modules }) { + modulesArray.append(m); + } + importError["modules"] = modulesArray; + moduleInfo["import-error"] = importError; + + cmGeneratedFileStream mf(cmStrCat(dir, "/CXXModules.json")); + mf << moduleInfo; + } + } + } +#endif +} + bool cmGlobalGenerator::DiscoverSyntheticTargets() { for (auto const& gen : this->LocalGenerators) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index a1ac5abafd..3184a28e60 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -811,6 +811,7 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; bool ApplyCXXStdTarget(); + void WriteCxxImportErrorModules(); bool DiscoverSyntheticTargets(); bool AddHeaderSetVerification(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 022d16dd65..434bf68aa9 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2716,6 +2716,14 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( }; std::map mod_files; + struct ImportErrorInfo + { + std::string Message; + std::set Modules; + }; + std::vector importErrors; + Json::Value transitiveInterfaceObjects(Json::objectValue); + // Populate the module map with those provided by linked targets first. for (std::string const& linked_target_dir : linked_target_dirs) { std::string const ltmn = @@ -2785,6 +2793,42 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( } } } + Json::Value const& import_error = ltm["import-error"]; + if (import_error.isObject()) { + ImportErrorInfo info; + info.Message = import_error["message"].asString(); + Json::Value const& errModules = import_error["modules"]; + if (errModules.isArray()) { + for (auto const& m : errModules) { + info.Modules.insert(m.asString()); + } + } + if (!info.Modules.empty()) { + importErrors.push_back(std::move(info)); + } + } + Json::Value const& linked_interface_objects = ltm["interface-objects"]; + if (linked_interface_objects.isObject()) { + for (auto i = linked_interface_objects.begin(); + i != linked_interface_objects.end(); ++i) { + if (!transitiveInterfaceObjects.isMember(i.key().asString())) { + transitiveInterfaceObjects[i.key().asString()] = *i; + } + } + } + } + } + + if (!importErrors.empty()) { + for (cmScanDepInfo const& object : objects) { + for (auto const& r : object.Requires) { + for (auto const& ie : importErrors) { + if (ie.Modules.count(r.LogicalName)) { + cmSystemTools::Error(ie.Message); + return false; + } + } + } } } @@ -3051,8 +3095,37 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( forward_info(tmi_target_modules, fmft["modules"]); forward_info(target_references, fmft["references"]); forward_info(target_usages, fmft["usages"]); + forward_info(transitiveInterfaceObjects, fmft["interface-objects"]); } + // Compute the set of modules actually imported by sources in this target. + std::set usedModules; + for (cmScanDepInfo const& object : objects) { + for (auto const& r : object.Requires) { + usedModules.insert(r.LogicalName); + } + } + + // Merge direct interface objects into the accumulated set. + // Direct objects are filtered: only keep those for modules that are + // actually imported by sources in this target. Transitive objects from + // linked targets were already filtered in their originating target. + if (cxx_interface_objects && cxx_interface_objects->isObject()) { + Json::Value const& directObjects = + (*cxx_interface_objects)["module-objects"]; + if (directObjects.isObject()) { + for (auto i = directObjects.begin(); i != directObjects.end(); ++i) { + std::string moduleName = i.key().asString(); + if (usedModules.count(moduleName) && + !transitiveInterfaceObjects.isMember(moduleName)) { + transitiveInterfaceObjects[i.key().asString()] = *i; + } + } + } + } + + target_module_info["interface-objects"] = transitiveInterfaceObjects; + cmGeneratedFileStream tmf(target_mods_file); tmf.SetCopyIfDifferent(true); tmf << target_module_info; @@ -3075,27 +3148,16 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( // Write the interface objects response file if configured. if (cxx_interface_objects && cxx_interface_objects->isObject()) { Json::Value const& rspFile = (*cxx_interface_objects)["rsp-file"]; - Json::Value const& moduleObjects = - (*cxx_interface_objects)["module-objects"]; - if (rspFile.isString() && moduleObjects.isObject()) { - std::set usedModules; - for (cmScanDepInfo const& object : objects) { - for (auto const& r : object.Requires) { - usedModules.insert(r.LogicalName); - } - } - + if (rspFile.isString()) { cmGeneratedFileStream rsp(rspFile.asString()); rsp.SetCopyIfDifferent(true); auto* lg = this->LocalGenerators.back().get(); - for (auto i = moduleObjects.begin(); i != moduleObjects.end(); ++i) { - std::string moduleName = i.key().asString(); - if (usedModules.count(moduleName)) { - rsp << lg->ConvertToOutputFormat( - lg->MaybeRelativeToTopBinDir((*i).asString()), - cmOutputConverter::RESPONSE) - << "\n"; - } + + for (auto const& objPath : transitiveInterfaceObjects) { + rsp << lg->ConvertToOutputFormat( + lg->MaybeRelativeToTopBinDir(objPath.asString()), + cmOutputConverter::RESPONSE) + << "\n"; } } } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 5a70c801d4..284c23c810 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -32,6 +32,10 @@ class cmMakefile; class cmake; struct cmCxxModuleExportInfo; +namespace Json { +class Value; +} + /** * \class cmGlobalNinjaGenerator * \brief Write a build.ninja file. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bbd05e402d..499a4e2baa 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -351,7 +351,6 @@ TargetProperty const StaticTargetProperties[] = { COMMON_LANGUAGE_PROPERTIES(C), // ---- C++ COMMON_LANGUAGE_PROPERTIES(CXX), - { "CXX_MODULE_STD"_s, IC::CanCompileSources }, // ---- CSharp { "DOTNET_SDK"_s, IC::NonImportedTarget }, { "DOTNET_TARGET_FRAMEWORK"_s, IC::TargetWithCommands }, @@ -1886,7 +1885,6 @@ void cmTarget::CopyCxxModulesProperties(cmTarget const* tgt) // ---- C++ "CXX_COMPILER_LAUNCHER", "CXX_VISIBILITY_PRESET", - "CXX_MODULE_STD", // Static analysis "CXX_CLANG_TIDY", diff --git a/Tests/RunCMake/CXXModules/CXXImportStdConfig-result.txt b/Tests/RunCMake/CXXModules/CXXImportStdConfig-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdConfig-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CXXModules/CXXImportStdConfig-stderr.txt b/Tests/RunCMake/CXXModules/CXXImportStdConfig-stderr.txt deleted file mode 100644 index 674cd16f28..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdConfig-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -CMake Error in CMakeLists\.txt: - The "CXX_MODULE_STD" property on the target "nocxx23target" contains a - context-sensitive condition that is not supported\. diff --git a/Tests/RunCMake/CXXModules/CXXImportStdConfig.cmake b/Tests/RunCMake/CXXModules/CXXImportStdConfig.cmake deleted file mode 100644 index 0867082798..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdConfig.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(CXX) - -set(CMAKE_CXX_MODULE_STD "$") - -add_library(nocxx23target) -target_sources(nocxx23target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx23target PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-result.txt b/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-stderr.txt b/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-stderr.txt deleted file mode 100644 index eeea7d0ae7..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget-stderr.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Error: - Error evaluating generator expression: - - \$ - - \$ may only be used with binary targets\. It may not - be used with add_custom_command or add_custom_target\. Specify the target - to read a property from using the \$ signature - instead\. diff --git a/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget.cmake b/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget.cmake deleted file mode 100644 index 3eb2c6835c..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdHeadTarget.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(CXX) - -set(CMAKE_CXX_MODULE_STD "$") - -add_library(nocxx23target) -target_sources(nocxx23target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx23target PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModules/CXXImportStdInvalidGenex.cmake b/Tests/RunCMake/CXXModules/CXXImportStdInvalidGenex.cmake deleted file mode 100644 index 86230a4d66..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdInvalidGenex.cmake +++ /dev/null @@ -1,11 +0,0 @@ -enable_language(CXX) -set(CMAKE_CXX_SCANDEP_SOURCE "echo") - -set(CMAKE_CXX_MODULE_STD "$ - - \$ may only be used with binary targets to specify link - libraries, link directories, link options and link depends\. diff --git a/Tests/RunCMake/CXXModules/CXXImportStdLinkLanguage.cmake b/Tests/RunCMake/CXXModules/CXXImportStdLinkLanguage.cmake deleted file mode 100644 index e9b20c7111..0000000000 --- a/Tests/RunCMake/CXXModules/CXXImportStdLinkLanguage.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(CXX) - -set(CMAKE_CXX_MODULE_STD "$") - -add_library(nocxx23target) -target_sources(nocxx23target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx23target PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModules/Inspect.cmake b/Tests/RunCMake/CXXModules/Inspect.cmake index 2ebb892bbe..de7775e9e0 100644 --- a/Tests/RunCMake/CXXModules/Inspect.cmake +++ b/Tests/RunCMake/CXXModules/Inspect.cmake @@ -20,8 +20,6 @@ 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(have_cxx23_import_std \"${have_cxx23_import_std}\") -set(have_cxx26_import_std \"${have_cxx26_import_std}\") set(CMAKE_CXX_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\") set(CMAKE_CXX_OUTPUT_EXTENSION \"${CMAKE_CXX_OUTPUT_EXTENSION}\") set(CXXModules_default_build_type \"${CMAKE_BUILD_TYPE}\") diff --git a/Tests/RunCMake/CXXModules/NoCXX23TargetNotRequired.cmake b/Tests/RunCMake/CXXModules/NoCXX23TargetNotRequired.cmake deleted file mode 100644 index 2d9bffa1d5..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX23TargetNotRequired.cmake +++ /dev/null @@ -1,11 +0,0 @@ -enable_language(CXX) -set(CMAKE_CXX_SCANDEP_SOURCE "echo") - -set(CMAKE_CXX_MODULE_STD 0) - -add_library(nocxx23target) -target_sources(nocxx23target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx23target PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModules/NoCXX23TargetRequired-result.txt b/Tests/RunCMake/CXXModules/NoCXX23TargetRequired-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX23TargetRequired-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CXXModules/NoCXX23TargetRequired-stderr.txt b/Tests/RunCMake/CXXModules/NoCXX23TargetRequired-stderr.txt deleted file mode 100644 index 48a8b9480f..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX23TargetRequired-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error in CMakeLists\.txt: - The "CXX_MODULE_STD" property on target "nocxx23target" requires toolchain - support, but it was not provided. Reason: - - (Toolchain does not support discovering module metadata|Experimental `import std` support not enabled when detecting toolchain; it must be set before `CXX` is enabled \(usually a `project\(\)` call\)|Unsupported generator: [^\n]*) - - -CMake Generate step failed\. Build files cannot be regenerated correctly\. diff --git a/Tests/RunCMake/CXXModules/NoCXX23TargetRequired.cmake b/Tests/RunCMake/CXXModules/NoCXX23TargetRequired.cmake deleted file mode 100644 index fac05e2232..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX23TargetRequired.cmake +++ /dev/null @@ -1,11 +0,0 @@ -enable_language(CXX) -set(CMAKE_CXX_SCANDEP_SOURCE "echo") - -set(CMAKE_CXX_MODULE_STD 1) - -add_library(nocxx23target) -target_sources(nocxx23target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx23target PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModules/NoCXX23TargetUnset.cmake b/Tests/RunCMake/CXXModules/NoCXX23TargetUnset.cmake deleted file mode 100644 index be9c632240..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX23TargetUnset.cmake +++ /dev/null @@ -1,13 +0,0 @@ -enable_language(CXX) -set(CMAKE_CXX_SCANDEP_SOURCE "echo") - -# TODO(cxxmodules): Add instances of this test which test the policy -# of the property's unset behavior. -# set(CMAKE_CXX_MODULE_STD ...) - -add_library(nocxx23target) -target_sources(nocxx23target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx23target PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModules/NoCXX26TargetNotRequired.cmake b/Tests/RunCMake/CXXModules/NoCXX26TargetNotRequired.cmake deleted file mode 100644 index b91fa9b719..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX26TargetNotRequired.cmake +++ /dev/null @@ -1,11 +0,0 @@ -enable_language(CXX) -set(CMAKE_CXX_SCANDEP_SOURCE "echo") - -set(CMAKE_CXX_MODULE_STD 0) - -add_library(nocxx26target) -target_sources(nocxx26target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx26target PRIVATE cxx_std_26) diff --git a/Tests/RunCMake/CXXModules/NoCXX26TargetRequired-result.txt b/Tests/RunCMake/CXXModules/NoCXX26TargetRequired-result.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX26TargetRequired-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CXXModules/NoCXX26TargetRequired-stderr.txt b/Tests/RunCMake/CXXModules/NoCXX26TargetRequired-stderr.txt deleted file mode 100644 index b45b04e0d2..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX26TargetRequired-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error in CMakeLists\.txt: - The "CXX_MODULE_STD" property on target "nocxx26target" requires toolchain - support, but it was not provided. Reason: - - (Toolchain does not support discovering module metadata|Experimental `import std` support not enabled when detecting toolchain; it must be set before `CXX` is enabled \(usually a `project\(\)` call\)|Unsupported generator: [^\n]*) - - -CMake Generate step failed\. Build files cannot be regenerated correctly\. diff --git a/Tests/RunCMake/CXXModules/NoCXX26TargetRequired.cmake b/Tests/RunCMake/CXXModules/NoCXX26TargetRequired.cmake deleted file mode 100644 index 79dcb792e2..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX26TargetRequired.cmake +++ /dev/null @@ -1,11 +0,0 @@ -enable_language(CXX) -set(CMAKE_CXX_SCANDEP_SOURCE "echo") - -set(CMAKE_CXX_MODULE_STD 1) - -add_library(nocxx26target) -target_sources(nocxx26target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx26target PRIVATE cxx_std_26) diff --git a/Tests/RunCMake/CXXModules/NoCXX26TargetUnset.cmake b/Tests/RunCMake/CXXModules/NoCXX26TargetUnset.cmake deleted file mode 100644 index c7254900dd..0000000000 --- a/Tests/RunCMake/CXXModules/NoCXX26TargetUnset.cmake +++ /dev/null @@ -1,13 +0,0 @@ -enable_language(CXX) -set(CMAKE_CXX_SCANDEP_SOURCE "echo") - -# TODO(cxxmodules): Add instances of this test which test the policy -# of the property's unset behavior. -# set(CMAKE_CXX_MODULE_STD ...) - -add_library(nocxx26target) -target_sources(nocxx26target - PRIVATE - FILE_SET fs TYPE CXX_MODULES FILES - sources/module.cxx) -target_compile_features(nocxx26target PRIVATE cxx_std_26) diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 4412283a36..63f2126eb4 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -93,27 +93,6 @@ foreach (fileset_type IN LISTS fileset_types) run_cmake("NotCXXSource${fileset_type}") endforeach () -if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES) - run_cmake(CXXImportStdConfig) - run_cmake(CXXImportStdHeadTarget) - run_cmake(CXXImportStdLinkLanguage) - run_cmake(CXXImportStdInvalidGenex) -endif () - -if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND - NOT have_cxx23_import_std) - run_cmake(NoCXX23TargetUnset) - run_cmake(NoCXX23TargetNotRequired) - run_cmake(NoCXX23TargetRequired) -endif () - -if ("cxx_std_26" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND - NOT have_cxx26_import_std) - run_cmake(NoCXX26TargetUnset) - run_cmake(NoCXX26TargetNotRequired) - run_cmake(NoCXX26TargetRequired) -endif () - run_cmake(InstallBMI) run_cmake(InstallBMIGenericArgs) run_cmake(InstallBMIIgnore) diff --git a/Tests/RunCMake/CXXModulesCompile/RunCMakeTest.cmake b/Tests/RunCMake/CXXModulesCompile/RunCMakeTest.cmake index becb546549..4cbf13ee40 100644 --- a/Tests/RunCMake/CXXModulesCompile/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModulesCompile/RunCMakeTest.cmake @@ -233,11 +233,12 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION) if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND "import_std23" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(imp-std) - run_cxx_module_test(imp-dummy-std) set(RunCMake_CXXModules_NO_TEST 1) - run_cxx_module_test(imp-std-no-std-prop) + run_cxx_module_test(imp-std-no-std-json) unset(RunCMake_CXXModules_NO_TEST) + run_cxx_module_test(imp-dummy-std) run_cxx_module_test(imp-std-exp-no-std-build) + run_cxx_module_test(imp-std-shared) set(RunCMake_CXXModules_INSTALL 1) run_cxx_module_test(imp-std-exp-no-std-install) unset(RunCMake_CXXModules_INSTALL) @@ -249,10 +250,10 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION) set(RunCMake_CXXModules_INSTALL 1) run_cxx_module_test(imp-std-not-in-exp-install) unset(RunCMake_CXXModules_INSTALL) - run_cxx_module_test(imp-std-trans imp-std-trans-not-in-exp-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/imp-std-not-in-exp-install-install") + run_cxx_module_test(imp-std-trans imp-std-trans-not-in-exp-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/imp-std-not-in-exp-install-install" "-Dimport_std_not_in_export_cps_DIR=${RunCMake_BINARY_DIR}/imp-std-not-in-exp-install-install/lib/cmake/import_std_not_in_export_cps") run_cxx_module_test(imp-std-trans imp-std-trans-exp-no-std-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/imp-std-exp-no-std-build-build" -DEXPORT_NO_STD=1) - run_cxx_module_test(imp-std-trans imp-std-trans-exp-no-std-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/imp-std-exp-no-std-install-install" -DEXPORT_NO_STD=1) + run_cxx_module_test(imp-std-trans imp-std-trans-exp-no-std-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/imp-std-exp-no-std-install-install" "-Dimport_std_export_no_std_cps_DIR=${RunCMake_BINARY_DIR}/imp-std-exp-no-std-install-install/lib/cmake/import_std_export_no_std_cps" -DEXPORT_NO_STD=1) endif () endif () endif () diff --git a/Tests/RunCMake/CXXModulesCompile/imp-dummy-std/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-dummy-std/CMakeLists.txt index 8a0bdb522a..8463849503 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-dummy-std/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-dummy-std/CMakeLists.txt @@ -1,5 +1,5 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") set(CMAKE_CXX_STDLIB_MODULES_JSON "${CMAKE_CURRENT_LIST_DIR}/../dummy-std/manifest/dummy-std.modules.json" ) @@ -9,8 +9,6 @@ project(cxx_modules_import_std CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") -set(CMAKE_CXX_MODULE_STD 1) - add_executable(main main.cxx) target_compile_features(main PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/CMakeLists.txt index 361fc4476d..949c08414e 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/CMakeLists.txt @@ -1,5 +1,5 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) project(cxx_modules_import_std_export_no_std CXX) @@ -16,9 +16,6 @@ target_sources(import_std_export_no_std FILE_SET use_std TYPE CXX_MODULES FILES impl-uses-std.cxx) target_compile_features(import_std_export_no_std PUBLIC cxx_std_23) -set_property(TARGET import_std_export_no_std - PROPERTY - CXX_MODULE_STD "$>") add_executable(main main.cxx) @@ -36,6 +33,10 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/import_std_export_no_std-config.cmake" set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) ") +export(PACKAGE_INFO import_std_export_no_std_cps + EXPORT export + CXX_MODULES_DIRECTORY "import_std_export_no_std-cxx-modules-cps") + add_test(NAME main COMMAND main) set(generator diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/test/CMakeLists.txt index 7483b3f72a..be5683c708 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-build/test/CMakeLists.txt @@ -8,8 +8,8 @@ if (NOT TARGET CXXModules::import_std_export_no_std) "Missing imported target") endif () -function (check_property expected property) - get_property(actual TARGET CXXModules::import_std_export_no_std +function (check_property expected property target) + get_property(actual TARGET ${target} PROPERTY "${property}") if (NOT DEFINED actual) if (NOT expected STREQUAL "") @@ -22,12 +22,11 @@ function (check_property expected property) endif () endfunction () -check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES") -check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS") -check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES") -check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES") -check_property("" "INTERFACE_LINK_LIBRARIES") -check_property("$" "CXX_MODULE_STD") +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" CXXModules::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" CXXModules::import_std_export_no_std) +check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" CXXModules::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" CXXModules::import_std_export_no_std) +check_property("" "INTERFACE_LINK_LIBRARIES" CXXModules::import_std_export_no_std) # Extract the export-dependent targets from the export file. file(STRINGS "${import_std_export_no_std_DIR}/import_std_export_no_std-targets.cmake" usage_dependent_targets @@ -41,5 +40,17 @@ string(REPLACE "\"" "" usage_dependent_targets "${usage_dependent_targets}") if ("@cmake_cxx_std" IN_LIST usage_dependent_targets) message(SEND_ERROR - "The main export requires the '@cmake_cxx_std' target") + "The CMake config export requires the '@cmake_cxx_std' target") endif () + +# CPS import test +find_package(import_std_export_no_std_cps CONFIG REQUIRED) +if (NOT TARGET import_std_export_no_std_cps::import_std_export_no_std) + message(FATAL_ERROR "Missing CPS imported target") +endif () + +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "INTERFACE_LINK_LIBRARIES" import_std_export_no_std_cps::import_std_export_no_std) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/CMakeLists.txt index c249276be5..1f6deeeed9 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/CMakeLists.txt @@ -1,5 +1,5 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) project(cxx_modules_import_std_export_no_std CXX) @@ -14,9 +14,6 @@ target_sources(import_std_export_no_std FILE_SET use_std TYPE CXX_MODULES FILES impl-uses-std.cxx) target_compile_features(import_std_export_no_std PUBLIC cxx_std_23) -set_property(TARGET import_std_export_no_std - PROPERTY - CXX_MODULE_STD "$>") add_executable(main main.cxx) @@ -38,6 +35,11 @@ set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/import_std_export_no_std-config.cmake" DESTINATION "lib/cmake/import_std_export_no_std") +install(PACKAGE_INFO import_std_export_no_std_cps + EXPORT export + DESTINATION "lib/cmake/import_std_export_no_std_cps" + CXX_MODULES_DIRECTORY "import_std_export_no_std-cxx-modules-cps") + add_test(NAME main COMMAND main) set(generator @@ -56,6 +58,7 @@ add_test(NAME import_std_export_no_std_build "${CMAKE_COMMAND}" "-Dexpected_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu" "-Dimport_std_export_no_std_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/import_std_export_no_std" + "-Dimport_std_export_no_std_cps_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/import_std_export_no_std_cps" ${generator} -S "${CMAKE_CURRENT_SOURCE_DIR}/test" -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/test/CMakeLists.txt index 7483b3f72a..be5683c708 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-exp-no-std-install/test/CMakeLists.txt @@ -8,8 +8,8 @@ if (NOT TARGET CXXModules::import_std_export_no_std) "Missing imported target") endif () -function (check_property expected property) - get_property(actual TARGET CXXModules::import_std_export_no_std +function (check_property expected property target) + get_property(actual TARGET ${target} PROPERTY "${property}") if (NOT DEFINED actual) if (NOT expected STREQUAL "") @@ -22,12 +22,11 @@ function (check_property expected property) endif () endfunction () -check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES") -check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS") -check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES") -check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES") -check_property("" "INTERFACE_LINK_LIBRARIES") -check_property("$" "CXX_MODULE_STD") +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" CXXModules::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" CXXModules::import_std_export_no_std) +check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" CXXModules::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" CXXModules::import_std_export_no_std) +check_property("" "INTERFACE_LINK_LIBRARIES" CXXModules::import_std_export_no_std) # Extract the export-dependent targets from the export file. file(STRINGS "${import_std_export_no_std_DIR}/import_std_export_no_std-targets.cmake" usage_dependent_targets @@ -41,5 +40,17 @@ string(REPLACE "\"" "" usage_dependent_targets "${usage_dependent_targets}") if ("@cmake_cxx_std" IN_LIST usage_dependent_targets) message(SEND_ERROR - "The main export requires the '@cmake_cxx_std' target") + "The CMake config export requires the '@cmake_cxx_std' target") endif () + +# CPS import test +find_package(import_std_export_no_std_cps CONFIG REQUIRED) +if (NOT TARGET import_std_export_no_std_cps::import_std_export_no_std) + message(FATAL_ERROR "Missing CPS imported target") +endif () + +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" import_std_export_no_std_cps::import_std_export_no_std) +check_property("" "INTERFACE_LINK_LIBRARIES" import_std_export_no_std_cps::import_std_export_no_std) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-build-result.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-build-result.txt similarity index 100% rename from Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-build-result.txt rename to Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-build-result.txt diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-build-stdout.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-build-stdout.txt new file mode 100644 index 0000000000..45ff6a37bd --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-build-stdout.txt @@ -0,0 +1 @@ +CMAKE_CXX_STDLIB_MODULES_JSON set to empty string diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-stderr.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-stderr.txt similarity index 100% rename from Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-stderr.txt rename to Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json-stderr.txt diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json/CMakeLists.txt similarity index 63% rename from Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop/CMakeLists.txt rename to Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json/CMakeLists.txt index 982c7d6db7..367f611e48 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json/CMakeLists.txt @@ -1,13 +1,13 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) -project(cxx_modules_import_std_no_std_property CXX) +project(cxx_modules_import_std_no_json CXX) + +set(CMAKE_CXX_STDLIB_MODULES_JSON "") include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") -set(CMAKE_CXX_MODULE_STD 0) - add_executable(main main.cxx) target_compile_features(main PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json/main.cxx b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json/main.cxx new file mode 100644 index 0000000000..228f48bd27 --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-json/main.cxx @@ -0,0 +1,5 @@ +import std; + +int main() +{ +} diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-build-stdout.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-build-stdout.txt deleted file mode 100644 index a94f02af7a..0000000000 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop-build-stdout.txt +++ /dev/null @@ -1 +0,0 @@ -((GNU)?fatal error: unknown compiled module interface: no such module|(Clang)?module 'std' not found|(MSVC)?could not find module 'std') diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop/main.cxx b/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop/main.cxx deleted file mode 100644 index fee84f12c3..0000000000 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-no-std-prop/main.cxx +++ /dev/null @@ -1,6 +0,0 @@ -import std; - -int main(int argc, char* argv[]) -{ - return 0; -} diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/CMakeLists.txt index 4f77dcaed2..7d22c80069 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/CMakeLists.txt @@ -1,13 +1,11 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) project(cxx_modules_import_std_not_in_export CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") -set(CMAKE_CXX_MODULE_STD 1) - add_library(import_std_not_in_export) target_sources(import_std_not_in_export PUBLIC @@ -31,6 +29,10 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/import_std_not_in_export-config.cmake" set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) ") +export(PACKAGE_INFO import_std_not_in_export_cps + EXPORT export + CXX_MODULES_DIRECTORY "import_std_not_in_export-cxx-modules-cps") + add_test(NAME main COMMAND main) set(generator diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/test/CMakeLists.txt index a3cf78f164..c30e510aea 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-build/test/CMakeLists.txt @@ -5,11 +5,11 @@ find_package(import_std_not_in_export REQUIRED) if (NOT TARGET CXXModules::import_std_not_in_export) message(FATAL_ERROR - "Missing imported target") + "Missing CMake config imported target") endif () -function (check_property expected property) - get_property(actual TARGET CXXModules::import_std_not_in_export +function (check_property expected property target) + get_property(actual TARGET ${target} PROPERTY "${property}") if (NOT DEFINED actual) if (NOT expected STREQUAL "") @@ -22,12 +22,11 @@ function (check_property expected property) endif () endfunction () -check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES") -check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS") -check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES") -check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES") -check_property("" "INTERFACE_LINK_LIBRARIES") -check_property("1" "CXX_MODULE_STD") +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" CXXModules::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" CXXModules::import_std_not_in_export) +check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" CXXModules::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" CXXModules::import_std_not_in_export) +check_property("" "INTERFACE_LINK_LIBRARIES" CXXModules::import_std_not_in_export) # Extract the export-dependent targets from the export file. file(STRINGS "${import_std_not_in_export_DIR}/import_std_not_in_export-targets.cmake" usage_dependent_targets @@ -41,5 +40,17 @@ string(REPLACE "\"" "" usage_dependent_targets "${usage_dependent_targets}") if ("@cmake_cxx_std" IN_LIST usage_dependent_targets) message(SEND_ERROR - "The main export requires the '@cmake_cxx_std' target") + "The CMake config export requires the '@cmake_cxx_std' target") endif () + +# CPS import test +find_package(import_std_not_in_export_cps CONFIG REQUIRED) +if (NOT TARGET import_std_not_in_export_cps::import_std_not_in_export) + message(FATAL_ERROR "Missing CPS imported target") +endif () + +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "INTERFACE_LINK_LIBRARIES" import_std_not_in_export_cps::import_std_not_in_export) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/CMakeLists.txt index 0e2e1818f7..ed3b1360b2 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/CMakeLists.txt @@ -1,13 +1,11 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) project(cxx_modules_import_std_not_in_export CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") -set(CMAKE_CXX_MODULE_STD 1) - add_library(import_std_not_in_export) target_sources(import_std_not_in_export PUBLIC @@ -35,6 +33,11 @@ set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/import_std_not_in_export-config.cmake" DESTINATION "lib/cmake/import_std_not_in_export") +install(PACKAGE_INFO import_std_not_in_export_cps + EXPORT export + DESTINATION "lib/cmake/import_std_not_in_export_cps" + CXX_MODULES_DIRECTORY "import_std_not_in_export-cxx-modules-cps") + add_test(NAME main COMMAND main) set(generator @@ -53,6 +56,7 @@ add_test(NAME import_std_not_in_export_build "${CMAKE_COMMAND}" "-Dexpected_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu" "-Dimport_std_not_in_export_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/import_std_not_in_export" + "-Dimport_std_not_in_export_cps_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/import_std_not_in_export_cps" ${generator} -S "${CMAKE_CURRENT_SOURCE_DIR}/test" -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/test/CMakeLists.txt index a3cf78f164..b08e377a80 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/test/CMakeLists.txt @@ -8,8 +8,8 @@ if (NOT TARGET CXXModules::import_std_not_in_export) "Missing imported target") endif () -function (check_property expected property) - get_property(actual TARGET CXXModules::import_std_not_in_export +function (check_property expected property target) + get_property(actual TARGET ${target} PROPERTY "${property}") if (NOT DEFINED actual) if (NOT expected STREQUAL "") @@ -22,12 +22,11 @@ function (check_property expected property) endif () endfunction () -check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES") -check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS") -check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES") -check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES") -check_property("" "INTERFACE_LINK_LIBRARIES") -check_property("1" "CXX_MODULE_STD") +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" CXXModules::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" CXXModules::import_std_not_in_export) +check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" CXXModules::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" CXXModules::import_std_not_in_export) +check_property("" "INTERFACE_LINK_LIBRARIES" CXXModules::import_std_not_in_export) # Extract the export-dependent targets from the export file. file(STRINGS "${import_std_not_in_export_DIR}/import_std_not_in_export-targets.cmake" usage_dependent_targets @@ -41,5 +40,17 @@ string(REPLACE "\"" "" usage_dependent_targets "${usage_dependent_targets}") if ("@cmake_cxx_std" IN_LIST usage_dependent_targets) message(SEND_ERROR - "The main export requires the '@cmake_cxx_std' target") + "The CMake config export requires the '@cmake_cxx_std' target") endif () + +# CPS import test +find_package(import_std_not_in_export_cps CONFIG REQUIRED) +if (NOT TARGET import_std_not_in_export_cps::import_std_not_in_export) + message(FATAL_ERROR "Missing CPS imported target") +endif () + +check_property("" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_COMPILE_FEATURES" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES" import_std_not_in_export_cps::import_std_not_in_export) +check_property("" "INTERFACE_LINK_LIBRARIES" import_std_not_in_export_cps::import_std_not_in_export) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-shared-stderr.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-shared-stderr.txt new file mode 100644 index 0000000000..5b4728eb73 --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-shared-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(experimental\) at .*/Modules/Compiler/CMakeCommonCompilerMacros\.cmake:[0-9]* \(cmake_language\): + CMake's support for `import std;` in C\+\+23 and newer is experimental\. It + is meant only for experimentation and feedback to CMake developers\. +Call Stack \(most recent call first\): + .*/Modules/CMakeDetermineCompilerSupport\.cmake:[0-9]* \(cmake_cxx_find_modules_json\) + .*/Modules/CMakeTestCXXCompiler\.cmake:[0-9]* \(CMAKE_DETERMINE_COMPILER_SUPPORT\) + CMakeLists\.txt:[0-9]* \(project\) +This warning is for project developers\. Use -Wno-author or -Wno-experimental +to suppress it\. diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-shared/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/CMakeLists.txt new file mode 100644 index 0000000000..9e7c9f23d1 --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/CMakeLists.txt @@ -0,0 +1,54 @@ +set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") + +cmake_minimum_required(VERSION 3.29) +project(cxx_modules_import_std_shared CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(import_std_shared SHARED) +target_sources(import_std_shared + PUBLIC + FILE_SET use_std TYPE CXX_MODULES FILES + uses-std.cxx) +target_compile_features(import_std_shared PUBLIC cxx_std_23) + +add_executable(main + main.cxx) +target_link_libraries(main PRIVATE import_std_shared) + +install(TARGETS import_std_shared + EXPORT export + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + FILE_SET use_std DESTINATION "lib/cxx/miu") +export(EXPORT export + NAMESPACE CXXModules:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/import_std_shared-targets.cmake") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/import_std_shared-config.cmake" + "include(\"\${CMAKE_CURRENT_LIST_DIR}/import_std_shared-targets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) +") + +add_test(NAME main COMMAND main) + +set(generator + -G "${CMAKE_GENERATOR}") +if (CMAKE_GENERATOR_TOOLSET) + list(APPEND generator + -T "${CMAKE_GENERATOR_TOOLSET}") +endif () +if (CMAKE_GENERATOR_PLATFORM) + list(APPEND generator + -A "${CMAKE_GENERATOR_PLATFORM}") +endif () + +add_test(NAME import_std_shared_build + COMMAND + "${CMAKE_COMMAND}" + "-Dexpected_dir=${CMAKE_CURRENT_SOURCE_DIR}" + "-DCMAKE_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}" + "-DCMAKE_CXX_STDLIB_MODULES_JSON=${CMAKE_CXX_STDLIB_MODULES_JSON}" + ${generator} + -S "${CMAKE_CURRENT_SOURCE_DIR}/test" + -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-shared/main.cxx b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/main.cxx new file mode 100644 index 0000000000..c93bda4666 --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/main.cxx @@ -0,0 +1,7 @@ +import uses_std; + +int main(int argc, char* argv[]) +{ + static_cast(use_chrono()); + return 0; +} diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/CMakeLists.txt new file mode 100644 index 0000000000..b3cf24c78e --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/CMakeLists.txt @@ -0,0 +1,15 @@ +set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") + +cmake_minimum_required(VERSION 3.29) +project(cxx_modules_library CXX) + +find_package(import_std_shared REQUIRED) + +if (NOT TARGET CXXModules::import_std_shared) + message(FATAL_ERROR "Missing imported target") +endif () + +add_executable(main main.cxx) +target_compile_features(main PRIVATE cxx_std_23) +target_link_libraries(main PRIVATE CXXModules::import_std_shared) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/main.cxx b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/main.cxx new file mode 100644 index 0000000000..c93bda4666 --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/test/main.cxx @@ -0,0 +1,7 @@ +import uses_std; + +int main(int argc, char* argv[]) +{ + static_cast(use_chrono()); + return 0; +} diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-shared/uses-std.cxx b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/uses-std.cxx new file mode 100644 index 0000000000..cbeccd34dc --- /dev/null +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-shared/uses-std.cxx @@ -0,0 +1,16 @@ +export module uses_std; + +import std; + +#ifdef _WIN32 +export __declspec(dllexport) int dummy() +{ + return 0; +} +#endif + +export inline int use_chrono() +{ + static_cast(std::chrono::current_zone()); + return 42; +} diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std-trans/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std-trans/CMakeLists.txt index 8c6dccb198..e91debb6cc 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std-trans/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std-trans/CMakeLists.txt @@ -1,5 +1,5 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) @@ -13,11 +13,13 @@ else () set(package "import_std_not_in_export") endif () find_package("${package}" REQUIRED) - -set(CMAKE_CXX_MODULE_STD 0) +find_package("${package}_cps" REQUIRED) add_executable(main main.cxx) -target_link_libraries(main PRIVATE "CXXModules::${package}") +target_compile_features(main PRIVATE cxx_std_23) +target_link_libraries(main PRIVATE + "CXXModules::${package}" + "${package}_cps::${package}") add_test(NAME main COMMAND main) diff --git a/Tests/RunCMake/CXXModulesCompile/imp-std/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/imp-std/CMakeLists.txt index 3a81e064c5..0f420b94d4 100644 --- a/Tests/RunCMake/CXXModulesCompile/imp-std/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/imp-std/CMakeLists.txt @@ -1,13 +1,11 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) project(cxx_modules_import_std CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") -set(CMAKE_CXX_MODULE_STD 1) - add_executable(main main.cxx) target_compile_features(main PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-import-std/CMakeLists.txt b/Tests/RunCMake/FileAPI/codemodel-v2-import-std/CMakeLists.txt index 653d7b30b7..928b1dea40 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-import-std/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/codemodel-v2-import-std/CMakeLists.txt @@ -1,5 +1,5 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_minimum_required(VERSION 3.29) project(codemodel_v2_import_std CXX) @@ -8,8 +8,6 @@ cmake_file_api(QUERY API_VERSION 1 CODEMODEL 2) include("${CMAKE_CURRENT_SOURCE_DIR}/../../CXXModulesCompile/cxx-modules-rules.cmake") -set(CMAKE_CXX_MODULE_STD 1) - add_executable(main main.cxx) target_compile_features(main PRIVATE cxx_std_23) diff --git a/Tests/RunCMake/ToolchainSkipsChecks/CXX-toolchain.cmake b/Tests/RunCMake/ToolchainSkipsChecks/CXX-toolchain.cmake index 7b1db55e00..6fb39293e1 100644 --- a/Tests/RunCMake/ToolchainSkipsChecks/CXX-toolchain.cmake +++ b/Tests/RunCMake/ToolchainSkipsChecks/CXX-toolchain.cmake @@ -17,8 +17,6 @@ set(vars CMAKE_CXX_SIZEOF_DATA_PTR CMAKE_CXX_BYTE_ORDER CMAKE_CXX_COMPILER_ABI - - CMAKE_CXX_COMPILER_IMPORT_STD CMAKE_CXX_STDLIB_MODULES_JSON) foreach (std IN ITEMS 26 23 20 17 14 11 98) list(APPEND vars diff --git a/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-quiet.cmake b/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-quiet.cmake index 35387f4dcb..3536bcf7d1 100644 --- a/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-quiet.cmake +++ b/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-quiet.cmake @@ -13,7 +13,7 @@ if (NOT feature_present STREQUAL "FALSE") endif () set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED "CxxImportStd" diff --git a/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-set.cmake b/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-set.cmake index f4740c2f69..f456ad3ded 100644 --- a/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-set.cmake +++ b/Tests/RunCMake/cmake_language/Experimental/CxxImportStd-set.cmake @@ -1,5 +1,5 @@ set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "f35a9ac6-8463-4d38-8eec-5d6008153e7d") + "25d6f6aa-be65-4692-b44e-87b23e96d4e1") cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED "CxxImportStd" diff --git a/Tests/RunCMake/property_init/CompileSources.cmake b/Tests/RunCMake/property_init/CompileSources.cmake index 2d0106c25b..52fda45ed7 100644 --- a/Tests/RunCMake/property_init/CompileSources.cmake +++ b/Tests/RunCMake/property_init/CompileSources.cmake @@ -230,15 +230,6 @@ macro (add_language_properties lang std) ) endmacro () -set(_cmake_supported_import_std_experimental "") -cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED "CxxImportStd" _cmake_supported_import_std_experimental) -if(_cmake_supported_import_std_experimental) - list(APPEND properties - # property expected alias - "CXX_MODULE_STD" "ON" "" - ) -endif() - # Mock up knowing the standard flag. This doesn't actually build, so nothing # should care at this point. set(CMAKE_Cc_std_11_STANDARD_COMPILE_OPTION "-std=c11")