Experimental: Remove import std experimental gate

Fixes: #28014
This commit is contained in:
Vito Gamberini committed 2026-09-25 11:03:02 -04:00
1 parent b65a094a31
commit 4874f044bd
46 files changed
+95 -420

No files matched your search

-18
View File
@@ -59,24 +59,6 @@ When activated, this experimental feature provides the following:
.. _CPS: https://cps-org.github.io/cps/
.. |CPS| replace:: Common Package Specification
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 ``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
experimenting. It must be set before the ``CXX`` toolchain is discovered by
CMake, usually as part of a ``project()`` call.
When activated, this experimental feature provides the following:
* Targets may use ``import std;`` in any scanned C++ source file.
Build database support
======================
+2 -9
View File
@@ -86,6 +86,8 @@ modules includes:
``import std`` Support
======================
.. versionadded:: 4.5
Support for ``import std`` is limited to the following toolchain and standard
library combinations:
@@ -108,12 +110,6 @@ for ``IMPORTED`` targets.
``import std`` is available for all language standards which support C++ module
scanning (ie, C++20 and newer).
.. 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
=================
@@ -506,9 +502,6 @@ The set of sources which need to be scanned may be modified using the
:command:`target_sources`, :command:`target_compile_features`, and
:command:`set_property` commands.
Additionally, targets may use the :prop_tgt:`CXX_MODULE_STD` target property
to indicate that ``import std`` is desired within the target's sources.
Generate
^^^^^^^^
-1
View File
@@ -233,7 +233,6 @@ Properties on Targets
/prop_tgt/CXX_MODULE_SET
/prop_tgt/CXX_MODULE_SET_NAME
/prop_tgt/CXX_MODULE_SETS
/prop_tgt/CXX_MODULE_STD
/prop_tgt/CXX_SCAN_FOR_MODULES
/prop_tgt/CXX_STANDARD
/prop_tgt/CXX_STANDARD_REQUIRED
-2
View File
@@ -475,7 +475,6 @@ Variables that Control the Build
/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS
/variable/CMAKE_CUDA_RUNTIME_LIBRARY
/variable/CMAKE_CUDA_SEPARABLE_COMPILATION
/variable/CMAKE_CXX_MODULE_STD
/variable/CMAKE_CXX_SCAN_FOR_MODULES
/variable/CMAKE_DEBUG_POSTFIX
/variable/CMAKE_DEBUGGER_WORKING_DIRECTORY
@@ -644,7 +643,6 @@ Variables for Languages
/variable/CMAKE_CUDA_STANDARD_REQUIRED
/variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES
/variable/CMAKE_CXX_COMPILE_FEATURES
/variable/CMAKE_CXX_COMPILER_IMPORT_STD
/variable/CMAKE_CXX_EXTENSIONS
/variable/CMAKE_CXX_STANDARD
/variable/CMAKE_CXX_STANDARD_REQUIRED
-46
View File
@@ -1,46 +0,0 @@
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
``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
current build and will not appear in the exported interfaces of the targets.
When consumed, these targets will be reapplied as necessary.
.. note::
Similar to the introduction of :prop_tgt:`CXX_SCAN_FOR_MODULES`, this
property defaults to **not** adding ``import std`` support to targets using
``cxx_std_23`` without an explicit request in order to preserve existing
behavior for projects using C++23 without ``import std``. A future policy
to change the default behavior is expected once the feature sees wider
usage.
This property's value is not relevant for targets which disable scanning (see
:prop_tgt:`CXX_SCAN_FOR_MODULES`). Additionally, this property only applies to
targets utilizing C++23 (``cxx_std_23``) or newer.
The property supports
:manual:`generator expressions <cmake-generator-expressions(7)>`, however
expressions that depend upon the configuration, the consuming target, or the
linker language are not allowed. Whether a target uses ``import std`` should
not depend upon such things as it is a static property of the target's source
code.
Targets which are exported with C++ module sources will have this property's
resolved value exported.
+10
View File
@@ -0,0 +1,10 @@
import-std
----------
* The experimental gate for ``import std`` has been dropped. ``import std`` is
available for all C++20 and later code with :prop_tgt:`CXX_SCAN_FOR_MODULES`
enabled.
* 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.
@@ -1,20 +0,0 @@
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
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.
-20
View File
@@ -1,20 +0,0 @@
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
``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.
@@ -1,7 +1,7 @@
CMAKE_CXX_STDLIB_MODULES_JSON
-----------------------------
.. versionadded:: 4.2
.. versionadded:: 4.5
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
@@ -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)
-8
View File
@@ -29,14 +29,6 @@ cmExperimental::FeatureData const LookupTable[] = {
"only for experimentation and feedback to CMake developers.",
{},
cmExperimental::TryCompileCondition::Always },
// CxxImportStd
{ "CxxImportStd",
"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.",
{},
cmExperimental::TryCompileCondition::Always },
// MappedPackageInfo
{ "MappedPackageInfo",
"ababa1b5-7099-495f-a9cd-e22d38f274f2",
-1
View File
@@ -18,7 +18,6 @@ public:
enum class Feature
{
ExportPackageDependencies,
CxxImportStd,
MappedPackageInfo,
ExportBuildDatabase,
GenerateSbom,
-5
View File
@@ -5446,11 +5446,6 @@ bool CreateCxxStdlibTarget(cmMakefile* makefile, cmLocalGenerator* lg,
bool cmGeneratorTarget::ApplyCXXStdTarget()
{
if (!cmExperimental::HasSupportEnabled(
*this->Makefile, cmExperimental::Feature::CxxImportStd)) {
return true;
}
std::vector<std::string> const& configs =
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
@@ -1,5 +1,57 @@
include("${CMAKE_CURRENT_LIST_DIR}/check-json.cmake")
# The `import std` support targets are generated by CMake and their build
# database contents vary by toolchain (flags, depfile paths, module names,
# translation unit ordering, etc.). Ignore everything related to them so
# that the same expectations can be shared across platforms.
function (filter_import_std_sets json_in json_out)
set(json "${json_in}")
# Drop `@cmake_cxx_std@` sets.
string(JSON sets_len LENGTH "${json}" "sets")
if (sets_len GREATER 0)
math(EXPR last "${sets_len} - 1")
set(std_indices "")
foreach (idx RANGE "${last}")
string(JSON name GET "${json}" "sets" "${idx}" "name")
if (name MATCHES "^@cmake_cxx_std@")
list(APPEND std_indices "${idx}")
endif ()
endforeach ()
list(REVERSE std_indices)
foreach (idx IN LISTS std_indices)
string(JSON json REMOVE "${json}" "sets" "${idx}")
endforeach ()
endif ()
# Drop references to those sets from every `visible-sets` array.
string(JSON sets_len LENGTH "${json}" "sets")
if (sets_len GREATER 0)
math(EXPR last "${sets_len} - 1")
foreach (idx RANGE "${last}")
string(JSON vis_len LENGTH "${json}" "sets" "${idx}" "visible-sets")
if (vis_len GREATER 0)
math(EXPR vis_last "${vis_len} - 1")
set(vis_indices "")
foreach (vis_idx RANGE "${vis_last}")
string(JSON vis_name GET
"${json}" "sets" "${idx}" "visible-sets" "${vis_idx}")
if (vis_name MATCHES "^@cmake_cxx_std@")
list(APPEND vis_indices "${vis_idx}")
endif ()
endforeach ()
list(REVERSE vis_indices)
foreach (vis_idx IN LISTS vis_indices)
string(JSON json REMOVE
"${json}" "sets" "${idx}" "visible-sets" "${vis_idx}")
endforeach ()
endif ()
endforeach ()
endif ()
set("${json_out}" "${json}" PARENT_SCOPE)
endfunction ()
function (check_build_database expect_basename fname component)
if (component STREQUAL "NO_EXIST")
if (EXISTS "${RunCMake_TEST_BINARY_DIR}/${fname}")
@@ -70,6 +122,8 @@ function (check_build_database expect_basename fname component)
file(READ "${RunCMake_TEST_BINARY_DIR}/${fname}" actual)
file(READ "${expected_file}" expect)
filter_import_std_sets("${actual}" actual)
set(RunCMake_TEST_FAILED_before "${RunCMake_TEST_FAILED}")
set(RunCMake_TEST_FAILED "")
@@ -1,9 +0,0 @@
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\.
@@ -1,5 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
set(CMAKE_CXX_STDLIB_MODULES_JSON
"${CMAKE_CURRENT_LIST_DIR}/../dummy-std/manifest/dummy-std.modules.json"
)
@@ -1,9 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_export_no_std CXX)
@@ -1,9 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_export_no_std CXX)
@@ -1,9 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_no_json CXX)
@@ -1,9 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_not_in_export CXX)
@@ -1,9 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_not_in_export CXX)
@@ -1,9 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_shared CXX)
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_library CXX)
@@ -1,9 +0,0 @@
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\.
@@ -1,9 +0,0 @@
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\.
@@ -1,9 +0,0 @@
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\.
@@ -1,9 +0,0 @@
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\.
@@ -1,9 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std_transitive CXX)
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std CXX)
@@ -28,17 +28,17 @@ foreach (consumer IN LISTS expected_consumers)
file(READ "${depend_info_file}" depend_info_json)
# Extract linked-target-dirs array length and first element
# Extract linked-target-dirs.
string(JSON linked_dirs_len LENGTH "${depend_info_json}" "linked-target-dirs")
string(JSON linked_dirs GET "${depend_info_json}" "linked-target-dirs")
if (consumer STREQUAL "consumer20")
set(expected_linked_tgt_regex "^importable\.dir$")
set(expected_linked_tgt_regex "^importable\\.dir$")
set(expected_linked_tgt_desc "owning target dir for 'importable'")
set(expected_linked_tgt_has_bmi 0)
elseif (consumer STREQUAL "consumer23" OR
consumer STREQUAL "consumer23flag")
set(expected_linked_tgt_regex "^importable@synth_[A-Za-z0-9_]+\.dir$")
set(expected_linked_tgt_regex "^importable@synth_[A-Za-z0-9_]+\\.dir$")
set(expected_linked_tgt_desc "shared synthetic target dir for 'importable'")
set(expected_linked_tgt_has_bmi 1)
else ()
@@ -53,35 +53,40 @@ foreach (consumer IN LISTS expected_consumers)
continue()
endif ()
# For this test, expect exactly one linked target dir per consumer
if (NOT linked_dirs_len EQUAL 1)
set(importable_dirs "")
set(linked_dir "")
set(linked_tgt_name "")
foreach (idx RANGE "${linked_dirs_len}")
if (idx EQUAL linked_dirs_len)
break ()
endif ()
string(JSON candidate GET "${depend_info_json}" "linked-target-dirs" "${idx}")
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
cmake_path(GET candidate PARENT_PATH candidate_root)
else ()
set(candidate_root "${candidate}")
endif ()
cmake_path(GET candidate_root FILENAME candidate_name)
if (candidate_name MATCHES "^importable(@synth_[A-Za-z0-9_]+)?\\.dir$")
list(APPEND importable_dirs "${candidate}")
set(linked_dir "${candidate}")
set(linked_tgt_name "${candidate_name}")
endif ()
endforeach ()
list(LENGTH importable_dirs importable_dirs_len)
if (NOT importable_dirs_len EQUAL 1)
list(APPEND RunCMake_TEST_FAILED
"Expected 1 linked-target-dir for '${consumer}' but found ${linked_dirs_len}: ${linked_dirs}")
continue()
"Expected exactly one 'importable' linked-target-dir for '${consumer}' but found ${importable_dirs_len}: ${linked_dirs}")
continue ()
endif ()
string(JSON linked_dir GET "${depend_info_json}" "linked-target-dirs" 0)
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
cmake_path(GET linked_dir PARENT_PATH linked_tgt_root)
else ()
set(linked_tgt_root "${linked_dir}")
endif ()
cmake_path(GET linked_tgt_root FILENAME linked_tgt_name)
if (NOT linked_tgt_name MATCHES "${expected_linked_tgt_regex}")
list(APPEND RunCMake_TEST_FAILED
"Consumer '${consumer}' should link to ${expected_linked_tgt_desc} but found ${linked_dir}")
continue()
endif ()
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(linked_output_dir "${linked_dir}/${config_dir}")
else ()
set(linked_output_dir "${linked_dir}")
endif ()
# Verify the linked target dir exists and contains a BMI
if (NOT EXISTS "${linked_dir}")
list(APPEND RunCMake_TEST_FAILED
@@ -1,12 +0,0 @@
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\.
@@ -1,6 +1,3 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
cmake_minimum_required(VERSION 3.29)
project(codemodel_v2_import_std CXX)
@@ -1,25 +0,0 @@
cmake_diagnostic(SET CMD_EXPERIMENTAL IGNORE)
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 ()
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
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 ()
@@ -1,7 +0,0 @@
^CMake Warning \(experimental\) 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-author or -Wno-experimental
to suppress it\.$
@@ -1,11 +0,0 @@
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
"25d6f6aa-be65-4692-b44e-87b23e96d4e1")
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 ()
@@ -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 ()
@@ -1,27 +0,0 @@
^CMake Warning \(experimental\) 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-author or -Wno-experimental
to suppress it\.
+
CMake Warning \(experimental\) 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-author or -Wno-experimental
to suppress it\.$
@@ -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)
@@ -158,10 +158,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/CxxImportStd-quiet)
run_cmake(Experimental/ExportPackageDependencies-set)
run_cmake(Experimental/ExportPackageDependencies-unset)
run_cmake(Experimental/ExportPackageDependencies-wrong)