From 80ef50a1919d62acb82a6423c40042a94edeac60 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 21 Nov 2022 13:36:47 -0500 Subject: CXXModules: add a variable for BMI-only compilation This will be required when dealing with imported targets which contain modules. --- .gitlab/ci/cxx_modules_rules_gcc.cmake | 1 + Help/dev/experimental.rst | 6 ++++++ Modules/Compiler/Clang-CXX.cmake | 1 + Modules/Compiler/MSVC-CXX.cmake | 1 + 4 files changed, 9 insertions(+) diff --git a/.gitlab/ci/cxx_modules_rules_gcc.cmake b/.gitlab/ci/cxx_modules_rules_gcc.cmake index 3726f6d..020cb1f 100644 --- a/.gitlab/ci/cxx_modules_rules_gcc.cmake +++ b/.gitlab/ci/cxx_modules_rules_gcc.cmake @@ -17,3 +17,4 @@ string(CONCAT CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG " -fdeps-format=p1689r5" # Force C++ as a language. " -x c++") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_BMI_ONLY_FLAG "-fmodule-only") diff --git a/Help/dev/experimental.rst b/Help/dev/experimental.rst index 5bfbf8d..89ebb3f 100644 --- a/Help/dev/experimental.rst +++ b/Help/dev/experimental.rst @@ -99,6 +99,10 @@ dependencies to the file specified by the ```` placeholder. The ``CMAKE_EXPERIMENTAL_CXX_SCANDEP_DEPFILE_FORMAT`` file may be set to ``msvc`` for scandep rules which use ``msvc``-style dependency reporting. +In order to support ``IMPORTED`` targets with associated C++20 module sources, +the ``CMAKE_EXPERIMENTAL_CXX_MODULE_BMI_ONLY_FLAG`` variable must be provided +to have the compiler only output a BMI instead of a BMI and an object file. + The module dependencies should be written in the format described by the `P1689r5`_ paper. @@ -113,6 +117,8 @@ For compilers that generate module maps, tell CMake as follows: set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "gcc") set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "${compiler_flags_for_module_map} -fmodule-mapper=") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_BMI_ONLY_FLAG + "-fmodule-only") Currently, the only supported formats are, ``clang``, ``gcc``, and ``msvc``. The ``gcc`` format is described in the GCC documentation, but the relevant diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index a74e90b..1167ba8 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -43,5 +43,6 @@ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) " > ") set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "clang") set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_BMI_ONLY_FLAG "--precompile") endif() endif() diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 10a9073..b03f826 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -87,4 +87,5 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.34") set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_DEPFILE_FORMAT "msvc") set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "msvc") set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_BMI_ONLY_FLAG "-ifcOnly;-ifcOutput;") endif () -- cgit v0.12