Experimental: Remove import std experimental gate

Fixes: #27571
This commit is contained in:
Vito Gamberini
2026-02-04 11:31:38 -05:00
committed by Brad King
parent d979f3df74
commit 70c1f0f43d
38 changed files with 29 additions and 269 deletions

View File

@@ -94,31 +94,6 @@ When activated, this experimental feature provides the following:
described using |CPS|_. Refer to the :command:`find_package` documentation
for details.
C++ ``import std`` support
==========================
In order to activate support for ``import std`` in C++23 and newer targets,
set
* variable ``CMAKE_EXPERIMENTAL_CXX_IMPORT_STD`` to
* value ``d0edc3af-4c50-42ea-a356-e2862fe7a444``.
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
experimenting. It must be set before the ``CXX`` toolchain is discovered by
CMake, usually as part of a :command:`project` call.
When activated, this experimental feature provides the following:
* The :prop_tgt:`CXX_MODULE_STD` target property and its initializing variable
: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.
.. _CPS: https://cps-org.github.io/cps/
.. |CPS| replace:: Common Package Specification
Build database support
======================

View File

@@ -75,6 +75,8 @@ modules includes:
``import std`` Support
======================
.. versionadded:: 4.3
Support for ``import std`` is limited to the following toolchain and standard
library combinations:
@@ -86,12 +88,6 @@ library combinations:
The :variable:`CMAKE_CXX_COMPILER_IMPORT_STD` variable lists standard levels
which have support for ``import std`` in the active C++ toolchain.
.. note::
This support is provided only when experimental support for
``import std`` has been enabled by the
``CMAKE_EXPERIMENTAL_CXX_IMPORT_STD`` gate.
Generator Support
=================

View File

@@ -1,16 +1,11 @@
CXX_MODULE_STD
--------------
.. versionadded:: 3.30
.. versionadded:: 4.3
``CXX_MODULE_STD`` is a boolean specifying whether the target may use
``import std;`` its C++ sources or not.
.. note::
This setting is meaningful only when experimental support for ``import
std;`` has been enabled by the ``CMAKE_EXPERIMENTAL_CXX_IMPORT_STD`` gate.
When this property is explicitly set to ``ON``, CMake will add a dependency to
a target which provides the C++ standard library's modules for the C++
standard applied to the target. This target is only applicable within the

View File

@@ -0,0 +1,15 @@
import-std
----------
* The experimental gate for C++23's ``import std`` has been dropped.
* Variable :variable:`CMAKE_CXX_MODULE_STD` and property target
:prop_tgt:`CXX_MODULE_STD` control the availability of ``import std`` for
C++ targets.
* Read-only variable :variable:`CMAKE_CXX_COMPILER_IMPORT_STD` lists the C++
standard levels for which ``import std`` is available on the current
toolchain.
* Variable :variable:`CMAKE_CXX_STDLIB_MODULES_JSON` sets a specific module
metadata file which CMake will use for constructing ``import std`` instead
of relying on automatic detection via the current C++ compiler.

View File

@@ -1,14 +1,9 @@
CMAKE_CXX_COMPILER_IMPORT_STD
-----------------------------
.. versionadded:: 3.30
.. versionadded:: 4.3
A list of C++ standard levels for which ``import std`` support exists for the
current C++ toolchain. Support for C++\<NN\> may be detected using a
``<NN> IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD`` predicate with the
:command:`if` command.
.. note::
This variable is meaningful only when experimental support for ``import
std;`` has been enabled by the ``CMAKE_EXPERIMENTAL_CXX_IMPORT_STD`` gate.

View File

@@ -1,15 +1,10 @@
CMAKE_CXX_MODULE_STD
--------------------
.. versionadded:: 3.30
.. versionadded:: 4.3
Whether to add utility targets as dependencies to targets with at least
``cxx_std_23`` or not.
.. note::
This setting is meaningful only when experimental support for ``import
std;`` has been enabled by the ``CMAKE_EXPERIMENTAL_CXX_IMPORT_STD`` gate.
This variable is used to initialize the :prop_tgt:`CXX_MODULE_STD` property on
all targets. See that target property for additional information.

View File

@@ -1,7 +1,7 @@
CMAKE_CXX_STDLIB_MODULES_JSON
-----------------------------
.. versionadded:: 4.2
.. versionadded:: 4.3
This variable may be used to set the path to a metadata file for CMake to
understand how the ``import std`` target for the active CXX compiler should be

View File

@@ -220,17 +220,6 @@ function(cmake_cxx_find_modules_json)
return ()
endif ()
# Check the experimental flag. Check it here to avoid triggering warnings in
# situations that don't support the feature anyways.
set(_cmake_supported_import_std_experimental "")
cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED
"CxxImportStd"
_cmake_supported_import_std_experimental)
if (NOT _cmake_supported_import_std_experimental)
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "Experimental `import std` support not enabled when detecting toolchain; it must be set before `CXX` is enabled (usually a `project()` call)" PARENT_SCOPE)
return ()
endif ()
_cmake_cxx_find_modules_json()
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "${CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE}" PARENT_SCOPE)
set(CMAKE_CXX_STDLIB_MODULES_JSON "${CMAKE_CXX_STDLIB_MODULES_JSON}" PARENT_SCOPE)

View File

@@ -29,14 +29,6 @@ cmExperimental::FeatureData const LookupTable[] = {
"only for experimentation and feedback to CMake developers.",
{},
cmExperimental::TryCompileCondition::Always },
// CxxImportStd
{ "CxxImportStd",
"d0edc3af-4c50-42ea-a356-e2862fe7a444",
"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.",
{},
cmExperimental::TryCompileCondition::Always },
// ImportPackageInfo
{ "ImportPackageInfo",
"e82e467b-f997-4464-8ace-b00808fff261",

View File

@@ -18,7 +18,6 @@ public:
enum class Feature
{
ExportPackageDependencies,
CxxImportStd,
ImportPackageInfo,
ExportPackageInfo,
MappedPackageInfo,

View File

@@ -5305,18 +5305,6 @@ bool cmGeneratorTarget::ApplyCXXStdTargets()
">:", cxxTargetName, ">>"));
}
// 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;
}
return true;
}

View File

@@ -2,7 +2,7 @@ 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]*)
(Toolchain does not support discovering module metadata|Unsupported generator: [^\n]*|Only `libc\+\+` and `libstdc\+\+` are supported)
CMake Generate step failed\. Build files cannot be regenerated correctly\.

View File

@@ -2,7 +2,7 @@ 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]*)
(Toolchain does not support discovering module metadata|Unsupported generator: [^\n]*|Only `libc\+\+` and `libstdc\+\+` are supported)
CMake Generate step failed\. Build files cannot be regenerated correctly\.

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_export_no_std CXX)

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_export_no_std CXX)

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_no_std_property CXX)

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_not_in_export CXX)

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_not_in_export CXX)

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,8 +0,0 @@
CMake Warning \(dev\) 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-dev to suppress it\.

View File

@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_minimum_required(VERSION 3.29)
if (EXPORT_NO_STD)

View File

@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std CXX)

View File

@@ -1,6 +0,0 @@
^CMake Warning \(dev\) at Experimental/CxxImportStd-set\.cmake:4 \(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\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-dev to suppress it\.$

View File

@@ -1,11 +0,0 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"d0edc3af-4c50-42ea-a356-e2862fe7a444")
cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED
"CxxImportStd"
feature_present)
if (NOT feature_present STREQUAL "TRUE")
message(FATAL_ERROR
"Expected the `CxxImportStd` feature to be enabled.")
endif ()

View File

@@ -1,8 +0,0 @@
cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED
"CxxImportStd"
feature_present)
if (NOT feature_present STREQUAL "FALSE")
message(FATAL_ERROR
"Expected the `CxxImportStd` feature to be disabled.")
endif ()

View File

@@ -1,25 +0,0 @@
^CMake Warning \(dev\) at Experimental/CxxImportStd-wrong\.cmake:4 \(cmake_language\):
CMAKE_EXPERIMENTAL_CXX_IMPORT_STD is set to incorrect value
01234567-0123-0123-0123-0123456789ab
See 'Help/dev/experimental\.rst' in the source tree of this version of CMake
for documentation of the experimental feature and the corresponding
activation value\. This project's code may require changes to work with
this CMake's version of the feature\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-dev to suppress it\.
+
CMake Warning \(dev\) at Experimental/CxxImportStd-wrong\.cmake:19 \(cmake_language\):
CMAKE_EXPERIMENTAL_CXX_IMPORT_STD is set to incorrect value
76543210-3210-3210-3210-ba9876543210
See 'Help/dev/experimental\.rst' in the source tree of this version of CMake
for documentation of the experimental feature and the corresponding
activation value\. This project's code may require changes to work with
this CMake's version of the feature\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers\. Use -Wno-dev to suppress it\.$

View File

@@ -1,21 +0,0 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"01234567-0123-0123-0123-0123456789ab")
cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED
"CxxImportStd"
feature_present)
if (NOT feature_present STREQUAL "FALSE")
message(FATAL_ERROR
"Expected the `CxxImportStd` feature to be disabled.")
endif ()
# Test if/when warning is repeated.
cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED
"CxxImportStd"
feature_present)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"76543210-3210-3210-3210-ba9876543210")
cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED
"CxxImportStd"
feature_present)

View File

@@ -157,9 +157,6 @@ run_cmake_command(
-P ${RunCMake_SOURCE_DIR}/get_message_log_level.cmake
)
run_cmake(Experimental/CxxImportStd-set)
run_cmake(Experimental/CxxImportStd-unset)
run_cmake(Experimental/CxxImportStd-wrong)
run_cmake(Experimental/ExportPackageDependencies-set)
run_cmake(Experimental/ExportPackageDependencies-unset)
run_cmake(Experimental/ExportPackageDependencies-wrong)

View File

@@ -156,6 +156,7 @@ set(properties
"AUTOMOC_DEPEND_FILTERS" "FIRST<SEMI>SECOND" "<SAME>"
## C++
"CXX_SCAN_FOR_MODULES" "ON" "<SAME>"
"CXX_MODULE_STD" "ON" "<SAME>"
## Ninja
"JOB_POOL_COMPILE" "compile_pool" "<SAME>"
"JOB_POOL_LINK" "link_pool" "<SAME>"
@@ -230,15 +231,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" "<SAME>"
)
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")

View File

@@ -69,5 +69,9 @@ events:(
- "[^"]+")+
message: \|(
+ [^
]*)*)*
]*)*|
+ -
kind: "find-v1"(
[^
]*)+)*
\.\.\.$