@@ -107,7 +107,7 @@ std::unique_ptr<cmMakefileTargetGenerator> cmMakefileTargetGenerator::New(
107
107
return result;
108
108
}
109
109
110
- std::string cmMakefileTargetGenerator::GetConfigName ()
110
+ std::string cmMakefileTargetGenerator::GetConfigName () const
111
111
{
112
112
auto const & configNames = this ->LocalGenerator ->GetConfigNames ();
113
113
assert (configNames.size () == 1 );
@@ -2080,7 +2080,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries(
2080
2080
}
2081
2081
2082
2082
std::string cmMakefileTargetGenerator::CreateResponseFile (
2083
- const char * name, std::string const & options,
2083
+ const std::string& name, std::string const & options,
2084
2084
std::vector<std::string>& makefile_depends)
2085
2085
{
2086
2086
// FIXME: Find a better way to determine the response file encoding,
@@ -2126,7 +2126,8 @@ cmMakefileTargetGenerator::CreateLinkLineComputer(
2126
2126
2127
2127
void cmMakefileTargetGenerator::CreateLinkLibs (
2128
2128
cmLinkLineComputer* linkLineComputer, std::string& linkLibs,
2129
- bool useResponseFile, std::vector<std::string>& makefile_depends)
2129
+ bool useResponseFile, std::vector<std::string>& makefile_depends,
2130
+ ResponseFlagFor responseMode)
2130
2131
{
2131
2132
std::string frameworkPath;
2132
2133
std::string linkPath;
@@ -2139,20 +2140,13 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
2139
2140
if (useResponseFile &&
2140
2141
linkLibs.find_first_not_of (' ' ) != std::string::npos) {
2141
2142
// Lookup the response file reference flag.
2142
- std::string responseFlagVar =
2143
- cmStrCat (" CMAKE_" ,
2144
- this ->GeneratorTarget ->GetLinkerLanguage (this ->GetConfigName ()),
2145
- " _RESPONSE_FILE_LINK_FLAG" );
2146
- std::string responseFlag;
2147
- if (cmValue p = this ->Makefile ->GetDefinition (responseFlagVar)) {
2148
- responseFlag = *p;
2149
- } else {
2150
- responseFlag = " @" ;
2151
- }
2143
+ std::string responseFlag = this ->GetResponseFlag (responseMode);
2152
2144
2153
2145
// Create this response file.
2146
+ std::string responseFileName =
2147
+ (responseMode == Link) ? " linkLibs.rsp" : " deviceLinkLibs.rsp" ;
2154
2148
std::string link_rsp =
2155
- this ->CreateResponseFile (" linklibs.rsp " , linkLibs, makefile_depends);
2149
+ this ->CreateResponseFile (responseFileName , linkLibs, makefile_depends);
2156
2150
2157
2151
// Reference the response file.
2158
2152
linkLibs = cmStrCat (responseFlag,
@@ -2164,7 +2158,7 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
2164
2158
void cmMakefileTargetGenerator::CreateObjectLists (
2165
2159
bool useLinkScript, bool useArchiveRules, bool useResponseFile,
2166
2160
std::string& buildObjs, std::vector<std::string>& makefile_depends,
2167
- bool useWatcomQuote)
2161
+ bool useWatcomQuote, ResponseFlagFor responseMode )
2168
2162
{
2169
2163
std::string variableName;
2170
2164
std::string variableNameExternal;
@@ -2179,27 +2173,19 @@ void cmMakefileTargetGenerator::CreateObjectLists(
2179
2173
this ->WriteObjectsStrings (object_strings, responseFileLimit);
2180
2174
2181
2175
// Lookup the response file reference flag.
2182
- std::string responseFlagVar =
2183
- cmStrCat (" CMAKE_" ,
2184
- this ->GeneratorTarget ->GetLinkerLanguage (this ->GetConfigName ()),
2185
- " _RESPONSE_FILE_LINK_FLAG" );
2186
- std::string responseFlag;
2187
- if (cmValue p = this ->Makefile ->GetDefinition (responseFlagVar)) {
2188
- responseFlag = *p;
2189
- } else {
2190
- responseFlag = " @" ;
2191
- }
2176
+ std::string responseFlag = this ->GetResponseFlag (responseMode);
2192
2177
2193
2178
// Write a response file for each string.
2194
2179
const char * sep = " " ;
2195
2180
for (unsigned int i = 0 ; i < object_strings.size (); ++i) {
2196
2181
// Number the response files.
2197
- char rsp[32 ];
2198
- snprintf (rsp, sizeof (rsp), " objects%u.rsp" , i + 1 );
2182
+ std::string responseFileName =
2183
+ (responseMode == Link) ? " objects" : " deviceObjects" ;
2184
+ responseFileName += std::to_string (i + 1 );
2199
2185
2200
2186
// Create this response file.
2201
- std::string objects_rsp =
2202
- this -> CreateResponseFile (rsp , object_strings[i], makefile_depends);
2187
+ std::string objects_rsp = this -> CreateResponseFile (
2188
+ responseFileName , object_strings[i], makefile_depends);
2203
2189
2204
2190
// Separate from previous response file references.
2205
2191
buildObjs += sep;
@@ -2251,7 +2237,7 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
2251
2237
}
2252
2238
std::string name = cmStrCat (" includes_" , lang, " .rsp" );
2253
2239
std::string arg = std::move (responseFlag) +
2254
- this ->CreateResponseFile (name. c_str () , includeFlags,
2240
+ this ->CreateResponseFile (name, includeFlags,
2255
2241
this ->FlagFileDepends [lang]);
2256
2242
this ->LocalGenerator ->AppendFlags (flags, arg);
2257
2243
} else {
@@ -2304,3 +2290,22 @@ void cmMakefileTargetGenerator::GenDefFile(
2304
2290
fout << src->GetFullPath () << " \n " ;
2305
2291
}
2306
2292
}
2293
+
2294
+ std::string cmMakefileTargetGenerator::GetResponseFlag (
2295
+ ResponseFlagFor mode) const
2296
+ {
2297
+ std::string responseFlag = " @" ;
2298
+ std::string responseFlagVar;
2299
+
2300
+ auto lang = this ->GeneratorTarget ->GetLinkerLanguage (this ->GetConfigName ());
2301
+ if (mode == cmMakefileTargetGenerator::ResponseFlagFor::Link) {
2302
+ responseFlagVar = cmStrCat (" CMAKE_" , lang, " _RESPONSE_FILE_LINK_FLAG" );
2303
+ } else if (mode == cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink) {
2304
+ responseFlagVar = " CMAKE_CUDA_RESPONSE_FILE_DEVICE_LINK_FLAG" ;
2305
+ }
2306
+
2307
+ if (cmValue p = this ->Makefile ->GetDefinition (responseFlagVar)) {
2308
+ responseFlag = *p;
2309
+ }
2310
+ return responseFlag;
2311
+ }
0 commit comments