From 4f0410959ec014bdb8d9838a36ae37e31b98318d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 21 Sep 2023 09:41:26 -0400 Subject: GCC: add rules for scanning C++ module dependencies --- Modules/Compiler/GNU-CXX.cmake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index b35f254..c276f4e 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -72,3 +72,24 @@ elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) endif() __compiler_check_default_language_standard(CXX 3.4 98 6.0 14 11.1 17) + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) + string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE + " -E -x c++ " + " -MT -MD -MF " + " -fmodules-ts -fdeps-file= -fdeps-target= -fdeps-format=p1689r5" + " -o ") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "gcc") + string(CONCAT CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG + # Turn on modules. + "-fmodules-ts" + # Read the module mapper file. + " -fmodule-mapper=" + # Make sure dependency tracking is enabled (missing from `try_*`). + " -MD" + # Suppress `CXX_MODULES +=` from generated depfile snippets. + " -fdeps-format=p1689r5" + # Force C++ as a language. + " -x c++") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_BMI_ONLY_FLAG "-fmodule-only") +endif() -- cgit v0.12