diff options
author | Benjamin Buch <benjamin.buch@technoteam.de> | 2023-06-07 10:15:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-06-07 14:05:39 (GMT) |
commit | f694e8d9c8176c7c98938031b0be3955fe70166b (patch) | |
tree | 3ad4ca772b2a25f57420fbd249e495191b00876e | |
parent | 8600fb263b71658e2e79c682f6abb991b2139d10 (diff) | |
download | CMake-f694e8d9c8176c7c98938031b0be3955fe70166b.zip CMake-f694e8d9c8176c7c98938031b0be3955fe70166b.tar.gz CMake-f694e8d9c8176c7c98938031b0be3955fe70166b.tar.bz2 |
cmcldeps: Do not pass linker flags to cl
Avoid cl `Command line warning D9035`.
Fixes: #24906
Co-authored-by: Brad King <brad.king@kitware.com>
-rw-r--r-- | Source/cmcldeps.cxx | 24 |
1 files 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 "; |