Tests/CXXModules: test forced rsp files with ninja

Fixes: #25367
This commit is contained in:
Ben Boeckel
2023-10-27 23:25:49 -04:00
parent e3747a2d4b
commit 09c962a6a4
4 changed files with 52 additions and 2 deletions

View File

@@ -1257,8 +1257,6 @@ cmNinjaBuild GetScanBuildStatement(const std::string& ruleName,
{
cmNinjaBuild scanBuild(ruleName);
scanBuild.RspFile = "$out.rsp";
if (compilePP) {
// Move compilation dependencies to the scan/preprocessing build statement.
std::swap(scanBuild.ExplicitDeps, objBuild.ExplicitDeps);
@@ -1299,6 +1297,7 @@ cmNinjaBuild GetScanBuildStatement(const std::string& ruleName,
// Tell dependency scanner where to store dyndep intermediate results.
std::string ddiFileName = cmStrCat(objectFileName, ".ddi");
scanBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] = ddiFileName;
scanBuild.RspFile = cmStrCat(ddiFileName, ".rsp");
// Outputs of the scan/preprocessor build statement.
if (compilePP) {

View File

@@ -0,0 +1,23 @@
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(path "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/impl-Debug.ninja")
else ()
set(path "${RunCMake_TEST_BINARY_DIR}/build.ninja")
endif ()
if (NOT EXISTS "${path}")
list(APPEND RunCMake_TEST_FAILED
"Failed to find `ninja` build file: '${path}'")
endif ()
file(READ "${path}" rspfiles
REGEX "^ *RSP_FILE =")
if (rspfiles MATCHES "\\$out\\.rsp$")
message(FATAL_ERROR
"rspfiles for modules should be specified explicitly")
elseif (NOT rspfiles MATCHES "ddi\\.rsp")
message(FATAL_ERROR
"rspfiles for scanning rules should be specified according to scan output filenames")
endif ()
string(REPLACE ";" "\n " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")

View File

@@ -0,0 +1,27 @@
# Fake out that we have dyndep; we only need to generate, not actually build
# here.
set(CMAKE_CXX_SCANDEP_SOURCE "")
enable_language(CXX)
if (NOT CMAKE_GENERATOR MATCHES "Ninja")
message(FATAL_ERROR
"This test requires a 'Ninja' generator to be used.")
endif ()
set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)
add_library(ninja-forced-response-file)
target_sources(ninja-forced-response-file
PRIVATE
FILE_SET modules TYPE CXX_MODULES
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/sources"
FILES
sources/module.cxx
sources/module-part.cxx
FILE_SET internal_partitions TYPE CXX_MODULES FILES
sources/module-internal-part.cxx)
target_compile_features(ninja-forced-response-file
PRIVATE
cxx_std_20)

View File

@@ -94,6 +94,7 @@ if (RunCMake_GENERATOR MATCHES "Ninja")
run_cmake(NinjaDependInfoFileSet)
run_cmake(NinjaDependInfoExport)
run_cmake(NinjaDependInfoBMIInstall)
run_cmake(NinjaForceResponseFile) # issue#25367
elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
run_cmake(VisualStudioNoSyntheticTargets)
else ()