diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2022-10-04 11:59:09 -0400 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2022-11-11 16:54:05 -0500 |
commit | 0e9782b336dbfd544257bee1da9a63cf84cfb058 (patch) | |
tree | add34472f5244fae2f132fc37b420ac5124fc48c | |
parent | d85f866baae609c91abc08b40cdccb28fd8c9f9c (diff) | |
download | cmake-0e9782b336dbfd544257bee1da9a63cf84cfb058.tar.gz |
msvc: bless MSVC 19.34 support for C++ modules as experimental
Visual Studio 17.4 now contains official support for what CMake needs.
-rw-r--r-- | .gitlab/ci/cxx_modules_rules_msvc.cmake | 10 | ||||
-rw-r--r-- | Help/dev/experimental.rst | 4 | ||||
-rw-r--r-- | Modules/Compiler/MSVC-CXX.cmake | 12 | ||||
-rw-r--r-- | Source/cmScanDepFormat.cxx | 22 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/NoCXX20ModuleFlag.cmake | 2 |
6 files changed, 19 insertions, 33 deletions
diff --git a/.gitlab/ci/cxx_modules_rules_msvc.cmake b/.gitlab/ci/cxx_modules_rules_msvc.cmake index 5f0ae7685c..2b09b0e26d 100644 --- a/.gitlab/ci/cxx_modules_rules_msvc.cmake +++ b/.gitlab/ci/cxx_modules_rules_msvc.cmake @@ -1,11 +1 @@ set(CMake_TEST_CXXModules_UUID "a246741c-d067-4019-a8fb-3d16b0c9d1d3") - -set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1) -string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE - "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> <SOURCE> -nologo -TP" - " -showIncludes" - " -scanDependencies <DYNDEP_FILE>" - " -Fo<OBJECT>") -set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_DEPFILE_FORMAT "msvc") -set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "msvc") -set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@<MODULE_MAP_FILE>") diff --git a/Help/dev/experimental.rst b/Help/dev/experimental.rst index adfa36fc7e..336137f5ff 100644 --- a/Help/dev/experimental.rst +++ b/Help/dev/experimental.rst @@ -39,6 +39,10 @@ they can use it to develop and test their dependency scanning tool. The ``CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE`` variable must also be set to tell CMake how to invoke the C++20 module dependency scanning tool. +MSVC 19.34 (provided with Visual Studio 17.4) and above contains the support +that CMake needs and has these variables already set up as required and only +the UUID variable needs to be set. + For example, add code like the following to a test project: .. code-block:: cmake diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 60d13f16cc..212f6d1958 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -77,3 +77,15 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) endmacro() endif() + +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.34") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1) + string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE + "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> <SOURCE> -nologo -TP" + " -showIncludes" + " -scanDependencies <DYNDEP_FILE>" + " -Fo<OBJECT>") + set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_DEPFILE_FORMAT "msvc") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "msvc") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@<MODULE_MAP_FILE>") +endif () diff --git a/Source/cmScanDepFormat.cxx b/Source/cmScanDepFormat.cxx index ec53af5382..81ef3da8ed 100644 --- a/Source/cmScanDepFormat.cxx +++ b/Source/cmScanDepFormat.cxx @@ -5,7 +5,6 @@ #include <cctype> #include <cstdio> -#include <iostream> #include <utility> #include <cm/optional> @@ -281,27 +280,6 @@ bool cmScanDepFormat_P1689_Parse(std::string const& arg_pp, info->Requires.push_back(require_info); } } - - // MSVC 17.3 toolchain bug. Remove when 17.4 is available. - if (rule.isMember("is-interface")) { - std::cerr - << "warning: acknowledging an VS 17.3 toolchain bug; accepting " - "until a new release which fixes it is available" - << std::endl; - - Json::Value const& is_interface_json = rule["is-interface"]; - if (!is_interface_json.isBool()) { - cmSystemTools::Error( - cmStrCat("-E cmake_ninja_dyndep failed to parse ", arg_pp, - ": is-interface is not a boolean")); - return false; - } - bool is_interface = is_interface_json.asBool(); - - for (auto& provide : info->Provides) { - provide.IsInterface = is_interface; - } - } } } diff --git a/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt b/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt index 5f90ec87c4..aa99af040a 100644 --- a/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt +++ b/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at NoCXX20ModuleFlag.cmake:4 \(target_sources\): +CMake Warning \(dev\) at NoCXX20ModuleFlag.cmake:6 \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag.cmake b/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag.cmake index 5f896f90d6..79892eed34 100644 --- a/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag.cmake +++ b/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag.cmake @@ -1,5 +1,7 @@ enable_language(CXX) +unset(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP) + add_library(noexperimentalflag) target_sources(noexperimentalflag PUBLIC |