summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-04-22 08:29:19 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-04-22 08:29:30 (GMT)
commit59c674917b8ceaeaaee69843358debb25b1f735a (patch)
tree254dfb55fa31a97c7170f9c3f14b62da67fdd89d /Source
parenta2fc16510ce3f89e34bd802c808d10951cfc94f5 (diff)
parente0364eb20dd69cc6db2981c33dc94ba353a5bc78 (diff)
downloadCMake-59c674917b8ceaeaaee69843358debb25b1f735a.zip
CMake-59c674917b8ceaeaaee69843358debb25b1f735a.tar.gz
CMake-59c674917b8ceaeaaee69843358debb25b1f735a.tar.bz2
Merge topic 'Link_instruction_in_RSP'
e0364eb20d Add support of CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_LIBRARIES variable. Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8409
Diffstat (limited to 'Source')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx38
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h2
2 files changed, 35 insertions, 5 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 4d68460..52c33f7 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -213,6 +213,22 @@ std::string cmNinjaNormalTargetGenerator::TextStubsGeneratorRule(
'_', config);
}
+bool cmNinjaNormalTargetGenerator::CheckUseResponseFileForLibraries(
+ const std::string& l) const
+{
+ // Check for an explicit setting one way or the other.
+ std::string const responseVar =
+ "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+
+ // If the option is defined, read it's value
+ if (cmValue val = this->Makefile->GetDefinition(responseVar)) {
+ return val.IsOn();
+ }
+
+ // Default to true
+ return true;
+}
+
struct cmNinjaRemoveNoOpCommands
{
bool operator()(std::string const& cmd)
@@ -251,9 +267,16 @@ void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkRule(
} else {
rule.RspContent = "$in_newline";
}
- rule.RspContent += " $LINK_LIBRARIES";
+
+ // add the link command in the file if necessary
+ if (this->CheckUseResponseFileForLibraries("CUDA")) {
+ rule.RspContent += " $LINK_LIBRARIES";
+ vars.LinkLibraries = "";
+ } else {
+ vars.LinkLibraries = "$LINK_PATH $LINK_LIBRARIES";
+ }
+
vars.Objects = responseFlag.c_str();
- vars.LinkLibraries = "";
}
vars.ObjectDir = "$OBJECT_DIR";
@@ -416,13 +439,20 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile,
} else {
rule.RspContent = "$in_newline";
}
- rule.RspContent += " $LINK_PATH $LINK_LIBRARIES";
+
+ // If libraries in rsp is enable
+ if (this->CheckUseResponseFileForLibraries(lang)) {
+ rule.RspContent += " $LINK_PATH $LINK_LIBRARIES";
+ vars.LinkLibraries = "";
+ } else {
+ vars.LinkLibraries = "$LINK_PATH $LINK_LIBRARIES";
+ }
+
if (this->TargetLinkLanguage(config) == "Swift") {
vars.SwiftSources = responseFlag.c_str();
} else {
vars.Objects = responseFlag.c_str();
}
- vars.LinkLibraries = "";
}
vars.ObjectDir = "$OBJECT_DIR";
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 85f42a4..187ea46 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -26,7 +26,7 @@ private:
const std::string& config) const;
std::string LanguageLinkerCudaFatbinaryRule(const std::string& config) const;
std::string TextStubsGeneratorRule(const std::string& config) const;
-
+ bool CheckUseResponseFileForLibraries(const std::string& config) const;
const char* GetVisibleTypeName() const;
void WriteLanguagesRules(const std::string& config);