From f694e8d9c8176c7c98938031b0be3955fe70166b Mon Sep 17 00:00:00 2001 From: Benjamin Buch Date: Wed, 7 Jun 2023 12:15:06 +0200 Subject: cmcldeps: Do not pass linker flags to cl Avoid cl `Command line warning D9035`. Fixes: #24906 Co-authored-by: Brad King --- Source/cmcldeps.cxx | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 708c2da..2fc1041 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -176,21 +176,6 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile, fclose(out); } -bool contains(const std::string& str, const std::string& what) -{ - return str.find(what) != std::string::npos; -} - -std::string replace(const std::string& str, const std::string& what, - const std::string& replacement) -{ - size_t pos = str.find(what); - if (pos == std::string::npos) - return str; - std::string replaced = str; - return replaced.replace(pos, what.size(), replacement); -} - static int process(cm::string_view srcfilename, const std::string& dfile, const std::string& objfile, const std::string& prefix, const std::string& cmd, const std::string& dir = "", @@ -266,10 +251,11 @@ int main() // "misuse" cl.exe to get headers from .rc files std::string clrest = " /nologo /showIncludes " + rest; - // rc: /fo x.dir\x.rc.res -> cl: /out:x.dir\x.rc.res.dep.obj - clrest = replace(clrest, "/fo ", "/out:"); - clrest = replace(clrest, "-fo ", "-out:"); - clrest = replace(clrest, objfile, objfile + ".dep.obj "); + // rc /fo X.dir\x.rc.res => cl -FoX.dir\x.rc.res.obj + // The object will not actually be written. + cmSystemTools::ReplaceString(clrest, "/fo ", " "); + cmSystemTools::ReplaceString(clrest, "-fo ", " "); + cmSystemTools::ReplaceString(clrest, objfile, "-Fo" + objfile + ".obj"); cl = "\"" + cl + "\" /P /DRC_INVOKED /TC "; -- cgit v0.12