summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-06-07 13:58:52 (GMT)
committerBrad King <brad.king@kitware.com>2023-06-07 14:12:57 (GMT)
commit0e1abf7afaa381b97cdc1435b42c7cfb00efa4e7 (patch)
treef58629ad5833c9a27ec5b4f5d485a45180f57930
parentf694e8d9c8176c7c98938031b0be3955fe70166b (diff)
downloadCMake-0e1abf7afaa381b97cdc1435b42c7cfb00efa4e7.zip
CMake-0e1abf7afaa381b97cdc1435b42c7cfb00efa4e7.tar.gz
CMake-0e1abf7afaa381b97cdc1435b42c7cfb00efa4e7.tar.bz2
cmcldeps: Avoid passing /nologo more than once to RC compiler
`rc /nologo /nologo ...` fails: fatal error RC1106: invalid option: -ologo Fixes: #24974 Inspired-by: Benjamin Buch <benjamin.buch@technoteam.de>
-rw-r--r--Source/cmcldeps.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index 2fc1041..72805d3 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -249,7 +249,16 @@ int main()
if (lang == "RC") {
// "misuse" cl.exe to get headers from .rc files
- std::string clrest = " /nologo /showIncludes " + rest;
+
+ // Make sure there is at most one /nologo option.
+ bool const haveNologo = (rest.find("/nologo ") != std::string::npos ||
+ rest.find("-nologo ") != std::string::npos);
+ cmSystemTools::ReplaceString(rest, "-nologo ", " ");
+ cmSystemTools::ReplaceString(rest, "/nologo ", " ");
+ std::string clrest = rest;
+ if (haveNologo) {
+ rest = "/nologo " + rest;
+ }
// rc /fo X.dir\x.rc.res => cl -FoX.dir\x.rc.res.obj
// The object will not actually be written.
@@ -257,7 +266,7 @@ int main()
cmSystemTools::ReplaceString(clrest, "-fo ", " ");
cmSystemTools::ReplaceString(clrest, objfile, "-Fo" + objfile + ".obj");
- cl = "\"" + cl + "\" /P /DRC_INVOKED /TC ";
+ cl = "\"" + cl + "\" /P /DRC_INVOKED /nologo /showIncludes /TC ";
// call cl in object dir so the .i is generated there
std::string objdir;