1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
|
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmSystemTools.h"
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <time.h>
#include <cmsys/RegularExpression.hxx>
#include <cmsys/Directory.hxx>
// support for realpath call
#ifndef _WIN32
#include <limits.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/wait.h>
#endif
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__))
#include <string.h>
#include <windows.h>
#include <direct.h>
#define _unlink unlink
#else
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#endif
bool cmSystemTools::s_RunCommandHideConsole = false;
bool cmSystemTools::s_DisableRunCommandOutput = false;
bool cmSystemTools::s_ErrorOccured = false;
bool cmSystemTools::s_FatalErrorOccured = false;
bool cmSystemTools::s_DisableMessages = false;
std::string cmSystemTools::s_Windows9xComspecSubstitute = "command.com";
void cmSystemTools::SetWindows9xComspecSubstitute(const char* str)
{
if ( str )
{
cmSystemTools::s_Windows9xComspecSubstitute = str;
}
}
const char* cmSystemTools::GetWindows9xComspecSubstitute()
{
return cmSystemTools::s_Windows9xComspecSubstitute.c_str();
}
void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&, void*);
void* cmSystemTools::s_ErrorCallbackClientData = 0;
// replace replace with with as many times as it shows up in source.
// write the result into source.
#if defined(_WIN32) && !defined(__CYGWIN__)
void cmSystemTools::ExpandRegistryValues(std::string& source)
{
// Regular expression to match anything inside [...] that begins in HKEY.
// Note that there is a special rule for regular expressions to match a
// close square-bracket inside a list delimited by square brackets.
// The "[^]]" part of this expression will match any character except
// a close square-bracket. The ']' character must be the first in the
// list of characters inside the [^...] block of the expression.
cmsys::RegularExpression regEntry("\\[(HKEY[^]]*)\\]");
// check for black line or comment
while (regEntry.find(source))
{
// the arguments are the second match
std::string key = regEntry.match(1);
std::string val;
if (ReadRegistryValue(key.c_str(), val))
{
std::string reg = "[";
reg += key + "]";
cmSystemTools::ReplaceString(source, reg.c_str(), val.c_str());
}
else
{
std::string reg = "[";
reg += key + "]";
cmSystemTools::ReplaceString(source, reg.c_str(), "/registry");
}
}
}
#else
void cmSystemTools::ExpandRegistryValues(std::string&)
{
}
#endif
std::string cmSystemTools::EscapeQuotes(const char* str)
{
std::string result = "";
for(const char* ch = str; *ch != '\0'; ++ch)
{
if(*ch == '"')
{
result += '\\';
}
result += *ch;
}
return result;
}
std::string cmSystemTools::EscapeSpaces(const char* str)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
std::string result;
// if there are spaces
std::string temp = str;
if (temp.find(" ") != std::string::npos &&
temp.find("\"")==std::string::npos)
{
result = "\"";
result += str;
result += "\"";
return result;
}
return str;
#else
std::string result = "";
for(const char* ch = str; *ch != '\0'; ++ch)
{
if(*ch == ' ')
{
result += '\\';
}
result += *ch;
}
return result;
#endif
}
std::string cmSystemTools::RemoveEscapes(const char* s)
{
std::string result = "";
for(const char* ch = s; *ch; ++ch)
{
if(*ch == '\\' && *(ch+1) != ';')
{
++ch;
switch (*ch)
{
case '\\': result.insert(result.end(), '\\'); break;
case '"': result.insert(result.end(), '"'); break;
case ' ': result.insert(result.end(), ' '); break;
case 't': result.insert(result.end(), '\t'); break;
case 'n': result.insert(result.end(), '\n'); break;
case 'r': result.insert(result.end(), '\r'); break;
case '#': result.insert(result.end(), '#'); break;
case '(': result.insert(result.end(), '('); break;
case ')': result.insert(result.end(), ')'); break;
case '0': result.insert(result.end(), '\0'); break;
case '\0':
{
cmSystemTools::Error("Trailing backslash in argument:\n", s);
return result;
}
default:
{
std::string chStr(1, *ch);
cmSystemTools::Error("Invalid escape sequence \\", chStr.c_str(),
"\nin argument ", s);
}
}
}
else
{
result.insert(result.end(), *ch);
}
}
return result;
}
void cmSystemTools::Error(const char* m1, const char* m2,
const char* m3, const char* m4)
{
std::string message = "CMake Error: ";
if(m1)
{
message += m1;
}
if(m2)
{
message += m2;
}
if(m3)
{
message += m3;
}
if(m4)
{
message += m4;
}
cmSystemTools::s_ErrorOccured = true;
cmSystemTools::Message(message.c_str(),"Error");
}
void cmSystemTools::SetErrorCallback(ErrorCallback f, void* clientData)
{
s_ErrorCallback = f;
s_ErrorCallbackClientData = clientData;
}
void cmSystemTools::Message(const char* m1, const char *title)
{
if(s_DisableMessages)
{
return;
}
if(s_ErrorCallback)
{
(*s_ErrorCallback)(m1, title, s_DisableMessages, s_ErrorCallbackClientData);
return;
}
else
{
std::cerr << m1 << std::endl << std::flush;
}
}
void cmSystemTools::ReportLastSystemError(const char* msg)
{
std::string m = msg;
m += ": System Error: ";
m += Superclass::GetLastSystemError();
cmSystemTools::Error(m.c_str());
}
bool cmSystemTools::IsOn(const char* val)
{
if (!val)
{
return false;
}
std::basic_string<char> v = val;
for(std::basic_string<char>::iterator c = v.begin();
c != v.end(); c++)
{
*c = toupper(*c);
}
return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y");
}
bool cmSystemTools::IsNOTFOUND(const char* val)
{
cmsys::RegularExpression reg("-NOTFOUND$");
if(reg.find(val))
{
return true;
}
return std::string("NOTFOUND") == val;
}
bool cmSystemTools::IsOff(const char* val)
{
if (!val || strlen(val) == 0)
{
return true;
}
std::basic_string<char> v = val;
for(std::basic_string<char>::iterator c = v.begin();
c != v.end(); c++)
{
*c = toupper(*c);
}
return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" ||
v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE");
}
bool cmSystemTools::RunCommand(const char* command,
std::string& output,
const char* dir,
bool verbose,
int timeout)
{
int dummy;
return cmSystemTools::RunCommand(command, output, dummy,
dir, verbose, timeout);
}
#if defined(WIN32) && !defined(__CYGWIN__)
#include "cmWin32ProcessExecution.h"
// use this for shell commands like echo and dir
bool RunCommandViaWin32(const char* command,
const char* dir,
std::string& output,
int& retVal,
bool verbose,
int timeout)
{
#if defined(__BORLANDC__)
return cmWin32ProcessExecution::BorlandRunCommand(command, dir, output,
retVal,
verbose, timeout,
cmSystemTools::GetRunCommandHideConsole());
#else // Visual studio
::SetLastError(ERROR_SUCCESS);
if ( ! command )
{
cmSystemTools::Error("No command specified");
return false;
}
cmWin32ProcessExecution resProc;
if(cmSystemTools::GetRunCommandHideConsole())
{
resProc.SetHideWindows(true);
}
if ( cmSystemTools::GetWindows9xComspecSubstitute() )
{
resProc.SetConsoleSpawn(cmSystemTools::GetWindows9xComspecSubstitute() );
}
if ( !resProc.StartProcess(command, dir, verbose) )
{
return false;
}
resProc.Wait(timeout);
output = resProc.GetOutput();
retVal = resProc.GetExitValue();
return true;
#endif
}
// use this for shell commands like echo and dir
bool RunCommandViaSystem(const char* command,
const char* dir,
std::string& output,
int& retVal,
bool verbose)
{
std::cout << "@@ " << command << std::endl;
std::string commandInDir;
if(dir)
{
commandInDir = "cd ";
commandInDir += cmSystemTools::ConvertToOutputPath(dir);
commandInDir += " && ";
commandInDir += command;
}
else
{
commandInDir = command;
}
command = commandInDir.c_str();
std::string commandToFile = command;
commandToFile += " > ";
std::string tempFile;
tempFile += _tempnam(0, "cmake");
commandToFile += tempFile;
retVal = system(commandToFile.c_str());
std::ifstream fin(tempFile.c_str());
if(!fin)
{
if(verbose)
{
std::string errormsg = "RunCommand produced no output: command: \"";
errormsg += command;
errormsg += "\"";
errormsg += "\nOutput file: ";
errormsg += tempFile;
cmSystemTools::Error(errormsg.c_str());
}
fin.close();
cmSystemTools::RemoveFile(tempFile.c_str());
return false;
}
bool multiLine = false;
std::string line;
while(cmSystemTools::GetLineFromStream(fin, line))
{
output += line;
if(multiLine)
{
output += "\n";
}
multiLine = true;
}
fin.close();
cmSystemTools::RemoveFile(tempFile.c_str());
return true;
}
#else // We have popen
bool RunCommandViaPopen(const char* command,
const char* dir,
std::string& output,
int& retVal,
bool verbose,
int /*timeout*/)
{
// if only popen worked on windows.....
std::string commandInDir;
if(dir)
{
commandInDir = "cd \"";
commandInDir += dir;
commandInDir += "\" && ";
commandInDir += command;
}
else
{
commandInDir = command;
}
commandInDir += " 2>&1";
command = commandInDir.c_str();
const int BUFFER_SIZE = 4096;
char buffer[BUFFER_SIZE];
if(verbose)
{
std::cout << "running " << command << std::endl;
}
fflush(stdout);
fflush(stderr);
FILE* cpipe = popen(command, "r");
if(!cpipe)
{
return false;
}
fgets(buffer, BUFFER_SIZE, cpipe);
while(!feof(cpipe))
{
if(verbose)
{
std::cout << buffer << std::flush;
}
output += buffer;
fgets(buffer, BUFFER_SIZE, cpipe);
}
retVal = pclose(cpipe);
if (WIFEXITED(retVal))
{
retVal = WEXITSTATUS(retVal);
return true;
}
if (WIFSIGNALED(retVal))
{
retVal = WTERMSIG(retVal);
cmOStringStream error;
error << "\nProcess terminated due to ";
switch (retVal)
{
#ifdef SIGKILL
case SIGKILL:
error << "SIGKILL";
break;
#endif
#ifdef SIGFPE
case SIGFPE:
error << "SIGFPE";
break;
#endif
#ifdef SIGBUS
case SIGBUS:
error << "SIGBUS";
break;
#endif
#ifdef SIGSEGV
case SIGSEGV:
error << "SIGSEGV";
break;
#endif
default:
error << "signal " << retVal;
break;
}
output += error.str();
}
return false;
}
#endif // endif WIN32 not CYGWIN
// run a command unix uses popen (easy)
// windows uses system and ShortPath
bool cmSystemTools::RunCommand(const char* command,
std::string& output,
int &retVal,
const char* dir,
bool verbose,
int timeout)
{
if(s_DisableRunCommandOutput)
{
verbose = false;
}
#if defined(WIN32) && !defined(__CYGWIN__)
// if the command does not start with a quote, then
// try to find the program, and if the program can not be
// found use system to run the command as it must be a built in
// shell command like echo or dir
int count = 0;
if(command[0] == '\"')
{
// count the number of quotes
for(const char* s = command; *s != 0; ++s)
{
if(*s == '\"')
{
count++;
if(count > 2)
{
break;
}
}
}
// if there are more than two double quotes use
// GetShortPathName, the cmd.exe program in windows which
// is used by system fails to execute if there are more than
// one set of quotes in the arguments
if(count > 2)
{
cmsys::RegularExpression quoted("^\"([^\"]*)\"[ \t](.*)");
if(quoted.find(command))
{
std::string shortCmd;
std::string cmd = quoted.match(1);
std::string args = quoted.match(2);
if(! cmSystemTools::FileExists(cmd.c_str()) )
{
shortCmd = cmd;
}
else if(!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd))
{
cmSystemTools::Error("GetShortPath failed for " , cmd.c_str());
return false;
}
shortCmd += " ";
shortCmd += args;
//return RunCommandViaSystem(shortCmd.c_str(), dir,
// output, retVal, verbose);
//return WindowsRunCommand(shortCmd.c_str(), dir,
//output, retVal, verbose);
return RunCommandViaWin32(shortCmd.c_str(), dir,
output, retVal, verbose, timeout);
}
else
{
cmSystemTools::Error("Could not parse command line with quotes ",
command);
}
}
}
// if there is only one set of quotes or no quotes then just run the command
//return RunCommandViaSystem(command, dir, output, retVal, verbose);
//return WindowsRunCommand(command, dir, output, retVal, verbose);
return ::RunCommandViaWin32(command, dir, output, retVal, verbose, timeout);
#else
return ::RunCommandViaPopen(command, dir, output, retVal, verbose, timeout);
#endif
}
bool cmSystemTools::DoesFileExistWithExtensions(
const char* name,
const std::vector<std::string>& headerExts)
{
std::string hname;
for( std::vector<std::string>::const_iterator ext = headerExts.begin();
ext != headerExts.end(); ++ext )
{
hname = name;
hname += ".";
hname += *ext;
if(cmSystemTools::FileExists(hname.c_str()))
{
return true;
}
}
return false;
}
bool cmSystemTools::cmCopyFile(const char* source, const char* destination)
{
return Superclass::CopyFileAlways(source, destination);
}
void cmSystemTools::Glob(const char *directory, const char *regexp,
std::vector<std::string>& files)
{
cmsys::Directory d;
cmsys::RegularExpression reg(regexp);
if (d.Load(directory))
{
size_t numf;
unsigned int i;
numf = d.GetNumberOfFiles();
for (i = 0; i < numf; i++)
{
std::string fname = d.GetFile(i);
if (reg.find(fname))
{
files.push_back(fname);
}
}
}
}
void cmSystemTools::GlobDirs(const char *fullPath,
std::vector<std::string>& files)
{
std::string path = fullPath;
std::string::size_type pos = path.find("/*");
if(pos == std::string::npos)
{
files.push_back(fullPath);
return;
}
std::string startPath = path.substr(0, pos);
std::string finishPath = path.substr(pos+2);
cmsys::Directory d;
if (d.Load(startPath.c_str()))
{
for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i)
{
if((std::string(d.GetFile(i)) != ".")
&& (std::string(d.GetFile(i)) != ".."))
{
std::string fname = startPath;
fname +="/";
fname += d.GetFile(i);
if(cmSystemTools::FileIsDirectory(fname.c_str()))
{
fname += finishPath;
cmSystemTools::GlobDirs(fname.c_str(), files);
}
}
}
}
}
void cmSystemTools::ExpandList(std::vector<std::string> const& arguments,
std::vector<std::string>& newargs)
{
std::vector<std::string>::const_iterator i;
for(i = arguments.begin();i != arguments.end(); ++i)
{
cmSystemTools::ExpandListArgument(*i, newargs);
}
}
void cmSystemTools::ExpandListArgument(const std::string& arg,
std::vector<std::string>& newargs)
{
std::string newarg;
// If argument is empty, it is an empty list.
if(arg.length() == 0)
{
return;
}
// if there are no ; in the name then just copy the current string
if(arg.find(';') == std::string::npos)
{
newargs.push_back(arg);
}
else
{
std::string::size_type start = 0;
std::string::size_type endpos = 0;
const std::string::size_type size = arg.size();
// break up ; separated sections of the string into separate strings
while(endpos != size)
{
endpos = arg.find(';', start);
if(endpos == std::string::npos)
{
endpos = arg.size();
}
else
{
// skip right over escaped ; ( \; )
while((endpos != std::string::npos)
&& (endpos > 0)
&& ((arg)[endpos-1] == '\\') )
{
endpos = arg.find(';', endpos+1);
}
if(endpos == std::string::npos)
{
endpos = arg.size();
}
}
std::string::size_type len = endpos - start;
if (len > 0)
{
// check for a closing ] after the start position
if(arg.find('[', start) == std::string::npos)
{
// if there is no [ in the string then keep it
newarg = arg.substr(start, len);
}
else
{
int opencount = 0;
int closecount = 0;
for(std::string::size_type j = start; j < endpos; ++j)
{
if(arg.at(j) == '[')
{
++opencount;
}
else if (arg.at(j) == ']')
{
++closecount;
}
}
if(opencount != closecount)
{
// skip this one
endpos = arg.find(';', endpos+1);
if(endpos == std::string::npos)
{
endpos = arg.size();
}
len = endpos - start;
}
newarg = arg.substr(start, len);
}
std::string::size_type pos = newarg.find("\\;");
if(pos != std::string::npos)
{
newarg.erase(pos, 1);
}
newargs.push_back(newarg);
}
start = endpos+1;
}
}
}
bool cmSystemTools::SimpleGlob(const std::string& glob,
std::vector<std::string>& files,
int type /* = 0 */)
{
files.clear();
if ( glob[glob.size()-1] != '*' )
{
return false;
}
std::string path = cmSystemTools::GetFilenamePath(glob);
std::string ppath = cmSystemTools::GetFilenameName(glob);
ppath = ppath.substr(0, ppath.size()-1);
if ( path.size() == 0 )
{
path = "/";
}
bool res = false;
cmsys::Directory d;
if (d.Load(path.c_str()))
{
for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i)
{
if((std::string(d.GetFile(i)) != ".")
&& (std::string(d.GetFile(i)) != ".."))
{
std::string fname = path;
if ( path[path.size()-1] != '/' )
{
fname +="/";
}
fname += d.GetFile(i);
std::string sfname = d.GetFile(i);
if ( type > 0 && cmSystemTools::FileIsDirectory(fname.c_str()) )
{
continue;
}
if ( type < 0 && !cmSystemTools::FileIsDirectory(fname.c_str()) )
{
continue;
}
if ( sfname.size() >= ppath.size() &&
sfname.substr(0, ppath.size()) ==
ppath )
{
files.push_back(fname);
res = true;
}
}
}
}
return res;
}
cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext)
{
if ( ! cext || *cext == 0 )
{
return cmSystemTools::NO_FILE_FORMAT;
}
//std::string ext = cmSystemTools::LowerCase(cext);
std::string ext = cext;
if ( ext == "c" || ext == ".c" ) { return cmSystemTools::C_FILE_FORMAT; }
if (
ext == "C" || ext == ".C" ||
ext == "M" || ext == ".M" ||
ext == "c++" || ext == ".c++" ||
ext == "cc" || ext == ".cc" ||
ext == "cpp" || ext == ".cpp" ||
ext == "cxx" || ext == ".cxx" ||
ext == "m" || ext == ".m" ||
ext == "mm" || ext == ".mm"
) { return cmSystemTools::CXX_FILE_FORMAT; }
if ( ext == "java" || ext == ".java" ) { return cmSystemTools::JAVA_FILE_FORMAT; }
if (
ext == "H" || ext == ".H" ||
ext == "h" || ext == ".h" ||
ext == "h++" || ext == ".h++" ||
ext == "hm" || ext == ".hm" ||
ext == "hpp" || ext == ".hpp" ||
ext == "hxx" || ext == ".hxx" ||
ext == "in" || ext == ".in" ||
ext == "txx" || ext == ".txx"
) { return cmSystemTools::HEADER_FILE_FORMAT; }
if ( ext == "rc" || ext == ".rc" ) { return cmSystemTools::RESOURCE_FILE_FORMAT; }
if ( ext == "def" || ext == ".def" ) { return cmSystemTools::DEFINITION_FILE_FORMAT; }
if ( ext == "lib" || ext == ".lib" ||
ext == "a" || ext == ".a") { return cmSystemTools::STATIC_LIBRARY_FILE_FORMAT; }
if ( ext == "o" || ext == ".o" ||
ext == "obj" || ext == ".obj") { return cmSystemTools::OBJECT_FILE_FORMAT; }
#ifdef __APPLE__
if ( ext == "dylib" || ext == ".dylib" )
{ return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; }
if ( ext == "so" || ext == ".so" ||
ext == "bundle" || ext == ".bundle" )
{ return cmSystemTools::MODULE_FILE_FORMAT; }
#else // __APPLE__
if ( ext == "so" || ext == ".so" ||
ext == "sl" || ext == ".sl" ||
ext == "dll" || ext == ".dll" )
{ return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; }
#endif // __APPLE__
return cmSystemTools::UNKNOWN_FILE_FORMAT;
}
bool cmSystemTools::Split(const char* s, std::vector<cmStdString>& l)
{
std::vector<std::string> temp;
if(!Superclass::Split(s, temp))
{
return false;
}
for(std::vector<std::string>::const_iterator i = temp.begin();
i != temp.end(); ++i)
{
l.push_back(*i);
}
return true;
}
|