Commit 15b3f6f0 authored by Ben Boeckel's avatar Ben Boeckel Committed by Brad King

ninja, rc: ignore CMAKE_NINJA_FORCE_RESPONSE_FILE for RC files

In commit v3.6.0-rc1~174^2 (Ninja: Honor CMAKE_NINJA_FORCE_RESPONSE_FILE
for compile rules, 2016-04-06), Ninja learned to look for
`CMAKE_NINJA_FORCE_RESPONSE_FILE` in the current scope or the
environment in order to force response file usage for all compilation
rules.

However, on Windows, the RC compiler goes through cmcldeps which does a
`replace(output, output + ".dep.obj")` on the command line. However,
with a response file (which we name `output + ".rsp"`), the response
file path is replaced instead causing the compiler to (correctly)
complain that the response file `output + ".dep.obj.rsp"` does not
exist.

What needs to happen is for cmcldeps to look through the response file,
replace *its* contents and place it in the `output + ".dep.obj.rsp"`
file.

Also add a test which actually compiles an RC file into a library and
executable for all generators on Windows and additionally test
`CMAKE_NINJA_FORCE_RESPONSE_FILE` for Ninja generators.

Fixes #16167.
parent d152ae12
Pipeline #17939 passed with stage
......@@ -316,7 +316,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
std::string rspcontent;
std::string responseFlag;
if (this->ForceResponseFile()) {
if (lang != "RC" && this->ForceResponseFile()) {
rspfile = "$RSP_FILE";
responseFlag = "@" + rspfile;
rspcontent = " $DEFINES $INCLUDES $FLAGS";
......@@ -593,7 +593,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->SetMsvcTargetPdbVariable(vars);
int const commandLineLengthLimit = this->ForceResponseFile() ? -1 : 0;
bool const isRC = (language == "RC");
int const commandLineLengthLimit =
((!isRC && this->ForceResponseFile())) ? -1 : 0;
std::string const rspfile = objectFileName + ".rsp";
this->GetGlobalGenerator()->WriteBuild(
......
......@@ -274,6 +274,9 @@ if(BUILD_TESTING)
endif()
if(TEST_RESOURCES)
ADD_TEST_MACRO(VSResource VSResource)
if (CMAKE_GENERATOR MATCHES "Ninja")
add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP)
endif ()
endif()
ADD_TEST_MACRO(MSManifest MSManifest)
ADD_TEST_MACRO(Simple Simple)
......
cmake_minimum_required(VERSION 2.8.4)
project(VSResourceNinjaForceRSP)
set(CMAKE_NINJA_FORCE_RESPONSE_FILE TRUE)
add_library(ResourceLib lib.cpp test.rc)
add_executable(VSResourceNinjaForceRSP main.cpp test.rc)
int main(int argc, char** argv)
{
(void)argc;
(void)argv;
return 0;
}
STRINGTABLE
BEGIN
1234 "5"
END
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment