~ubuntu-branches/ubuntu/utopic/cmake/utopic

« back to all changes in this revision

Viewing changes to Source/cmGeneratorExpression.cxx

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-10-10 12:54:39 UTC
  • mfrom: (1.14.7)
  • Revision ID: package-import@ubuntu.com-20131010125439-h0ahaj004on6oj92
Tags: 2.8.12-0ubuntu1
New upstream release LP: #1246701

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
  std::string result;
193
193
  std::string::size_type pos = 0;
194
194
  std::string::size_type lastPos = pos;
 
195
  int nestingLevel = 0;
195
196
  while((pos = input.find("$<", lastPos)) != input.npos)
196
197
    {
197
198
    result += input.substr(lastPos, pos - lastPos);
198
199
    pos += 2;
199
 
    int nestingLevel = 1;
 
200
    nestingLevel = 1;
200
201
    const char *c = input.c_str() + pos;
201
202
    const char * const cStart = c;
202
203
    for ( ; *c; ++c)
224
225
    pos += traversed;
225
226
    lastPos = pos;
226
227
    }
227
 
  result += input.substr(lastPos);
 
228
  if (nestingLevel == 0)
 
229
    {
 
230
    result += input.substr(lastPos);
 
231
    }
228
232
  return cmGeneratorExpression::StripEmptyListElements(result);
229
233
}
230
234
 
231
235
//----------------------------------------------------------------------------
 
236
static void prefixItems(const std::string &content, std::string &result,
 
237
                        const std::string &prefix)
 
238
{
 
239
  std::vector<std::string> entries;
 
240
  cmGeneratorExpression::Split(content, entries);
 
241
  const char *sep = "";
 
242
  for(std::vector<std::string>::const_iterator ei = entries.begin();
 
243
      ei != entries.end(); ++ei)
 
244
    {
 
245
    result += sep;
 
246
    sep = ";";
 
247
    if (!cmSystemTools::FileIsFullPath(ei->c_str())
 
248
        && cmGeneratorExpression::Find(*ei) == std::string::npos)
 
249
      {
 
250
      result += prefix;
 
251
      }
 
252
    result += *ei;
 
253
    }
 
254
}
 
255
 
 
256
//----------------------------------------------------------------------------
232
257
static std::string stripExportInterface(const std::string &input,
233
 
                          cmGeneratorExpression::PreprocessContext context)
 
258
                          cmGeneratorExpression::PreprocessContext context,
 
259
                          bool resolveRelative)
234
260
{
235
261
  std::string result;
236
262
 
 
263
  int nestingLevel = 0;
237
264
  std::string::size_type pos = 0;
238
265
  std::string::size_type lastPos = pos;
239
266
  while (true)
263
290
    const bool gotInstallInterface = input[pos + 2] == 'I';
264
291
    pos += gotInstallInterface ? sizeof("$<INSTALL_INTERFACE:") - 1
265
292
                               : sizeof("$<BUILD_INTERFACE:") - 1;
266
 
    int nestingLevel = 1;
 
293
    nestingLevel = 1;
267
294
    const char *c = input.c_str() + pos;
268
295
    const char * const cStart = c;
269
296
    for ( ; *c; ++c)
289
316
        else if(context == cmGeneratorExpression::InstallInterface
290
317
            && gotInstallInterface)
291
318
          {
292
 
          result += input.substr(pos, c - cStart);
 
319
          const std::string content = input.substr(pos, c - cStart);
 
320
          if (resolveRelative)
 
321
            {
 
322
            prefixItems(content, result, "${_IMPORT_PREFIX}/");
 
323
            }
 
324
          else
 
325
            {
 
326
            result += content;
 
327
            }
293
328
          }
294
329
        break;
295
330
        }
304
339
    pos += traversed;
305
340
    lastPos = pos;
306
341
    }
307
 
  result += input.substr(lastPos);
 
342
  if (nestingLevel == 0)
 
343
    {
 
344
    result += input.substr(lastPos);
 
345
    }
308
346
 
309
347
  return cmGeneratorExpression::StripEmptyListElements(result);
310
348
}
380
418
 
381
419
//----------------------------------------------------------------------------
382
420
std::string cmGeneratorExpression::Preprocess(const std::string &input,
383
 
                                              PreprocessContext context)
 
421
                                              PreprocessContext context,
 
422
                                              bool resolveRelative)
384
423
{
385
424
  if (context == StripAllGeneratorExpressions)
386
425
    {
388
427
    }
389
428
  else if (context == BuildInterface || context == InstallInterface)
390
429
    {
391
 
    return stripExportInterface(input, context);
 
430
    return stripExportInterface(input, context, resolveRelative);
392
431
    }
393
432
 
394
433
  assert(!"cmGeneratorExpression::Preprocess called with invalid args");