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
|
/*=========================================================================
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 "cmFindBase.h"
cmFindBase::cmFindBase()
{
this->AlreadyInCache = false;
this->AlreadyInCacheWithoutMetaInfo = false;
this->NoDefaultPath = false;
this->NoCMakePath = false;
this->NoCMakeEnvironmentPath = false;
this->NoSystemEnvironmentPath = false;
this->NoCMakeSystemPath = false;
this->FindRootPathMode = RootPathModeBoth;
// default is to search frameworks first on apple
#if defined(__APPLE__)
this->SearchFrameworkFirst = true;
this->SearchAppBundleFirst = true;
#else
this->SearchFrameworkFirst = false;
this->SearchAppBundleFirst = false;
#endif
this->SearchFrameworkOnly = false;
this->SearchFrameworkLast = false;
this->SearchAppBundleOnly = false;
this->SearchAppBundleLast = false;
this->GenericDocumentation =
" FIND_XXX(<VAR> name1 path1 path2 ...)\n"
"This is the short-hand signature for the command that "
"is sufficient in many cases. It is the same "
"as FIND_XXX(<VAR> name1 PATHS path2 path2 ...)\n"
" FIND_XXX(\n"
" <VAR> \n"
" name | NAMES name1 [name2 ...]\n"
" PATHS path1 [path2 ... ENV var]\n"
" [PATH_SUFFIXES suffix1 [suffix2 ...]]\n"
" [DOC \"cache documentation string\"]\n"
" [NO_DEFAULT_PATH]\n"
" [NO_CMAKE_ENVIRONMENT_PATH]\n"
" [NO_CMAKE_PATH]\n"
" [NO_SYSTEM_ENVIRONMENT_PATH]\n"
" [NO_CMAKE_SYSTEM_PATH]\n"
" )\n"
""
"This command is used to find a SEARCH_XXX_DESC. "
"A cache entry named by <VAR> is created to store the result "
"of this command. "
"If the SEARCH_XXX is found the result is stored in the variable "
"and the search will not be repeated unless the variable is cleared. "
"If nothing is found, the result will be "
"<VAR>-NOTFOUND, and the search will be attempted again the "
"next time FIND_XXX is invoked with the same variable. "
"The name of the SEARCH_XXX that "
"is searched for is specified by the names listed "
"after the NAMES argument. Additional search locations "
"can be specified after the PATHS argument. If ENV var is "
"found in the PATHS section the environment variable var "
"will be read and converted from a system environment variable to "
"a cmake style list of paths. For example ENV PATH would be a way "
"to list the system path variable. The argument "
"after DOC will be used for the documentation string in "
"the cache. PATH_SUFFIXES can be used to give sub directories "
"that will be appended to the search paths.\n"
"If NO_DEFAULT_PATH is specified, then no additional paths are "
"added to the search. "
"If NO_DEFAULT_PATH is not specified, the search process is as follows:\n"
"1. Search cmake specific environment variables. This "
"can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n"
""
" CMAKE_FRAMEWORK_PATH\n"
" CMAKE_APPBUNDLE_PATH\n"
" CMAKE_XXX_PATH\n"
"2. Search cmake variables with the same names as "
"the cmake specific environment variables. These "
"are intended to be used on the command line with a "
"-DVAR=value. This can be skipped if NO_CMAKE_PATH "
"is passed.\n"
""
" CMAKE_FRAMEWORK_PATH\n"
" CMAKE_APPBUNDLE_PATH\n"
" CMAKE_XXX_PATH\n"
"3. Search the standard system environment variables. "
"This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.\n"
" PATH\n"
" XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE
"4. Search cmake variables defined in the Platform files "
"for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH "
"is passed.\n"
" CMAKE_SYSTEM_FRAMEWORK_PATH\n"
" CMAKE_SYSTEM_APPBUNDLE_PATH\n"
" CMAKE_SYSTEM_XXX_PATH\n"
"5. Search the paths specified after PATHS or in the short-hand version "
"of the command.\n"
"On Darwin or systems supporting OSX Frameworks, the cmake variable"
" CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:\n"
" \"FIRST\" - Try to find frameworks before standard\n"
" libraries or headers. This is the default on Darwin.\n"
" \"LAST\" - Try to find frameworks after standard\n"
" libraries or headers.\n"
" \"ONLY\" - Only try to find frameworks.\n"
" \"NEVER\". - Never try to find frameworks.\n"
"On Darwin or systems supporting OSX Application Bundles, the cmake "
"variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the "
"following:\n"
" \"FIRST\" - Try to find application bundles before standard\n"
" programs. This is the default on Darwin.\n"
" \"LAST\" - Try to find application bundles after standard\n"
" programs.\n"
" \"ONLY\" - Only try to find application bundles.\n"
" \"NEVER\". - Never try to find application bundles.\n"
"The reason the paths listed in the call to the command are searched "
"last is that most users of CMake would expect things to be found "
"first in the locations specified by their environment. Projects may "
"override this behavior by simply calling the command twice:\n"
" FIND_XXX(<VAR> NAMES name PATHS paths NO_DEFAULT_PATH)\n"
" FIND_XXX(<VAR> NAMES name)\n"
"Once one of these calls succeeds the result variable will be set "
"and stored in the cache so that neither call will search again.";
}
bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
{
if(argsIn.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK");
if(ff == "NEVER")
{
this->SearchFrameworkLast = false;
this->SearchFrameworkFirst = false;
this->SearchFrameworkOnly = false;
}
else if (ff == "ONLY")
{
this->SearchFrameworkLast = false;
this->SearchFrameworkFirst = false;
this->SearchFrameworkOnly = true;
}
else if (ff == "FIRST")
{
this->SearchFrameworkLast = false;
this->SearchFrameworkFirst = true;
this->SearchFrameworkOnly = false;
}
else if (ff == "LAST")
{
this->SearchFrameworkLast = true;
this->SearchFrameworkFirst = false;
this->SearchFrameworkOnly = false;
}
std::string fab = this->Makefile->GetSafeDefinition("CMAKE_FIND_APPBUNDLE");
if(fab == "NEVER")
{
this->SearchAppBundleLast = false;
this->SearchAppBundleFirst = false;
this->SearchAppBundleOnly = false;
}
else if (fab == "ONLY")
{
this->SearchAppBundleLast = false;
this->SearchAppBundleFirst = false;
this->SearchAppBundleOnly = true;
}
else if (fab == "FIRST")
{
this->SearchAppBundleLast = false;
this->SearchAppBundleFirst = true;
this->SearchAppBundleOnly = false;
}
else if (fab == "LAST")
{
this->SearchAppBundleLast = true;
this->SearchAppBundleFirst = false;
this->SearchAppBundleOnly = false;
}
// CMake versions below 2.3 did not search all these extra
// locations. Preserve compatibility unless a modern argument is
// passed.
bool compatibility = false;
const char* versionValue =
this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
int major = 0;
int minor = 0;
if(versionValue && sscanf(versionValue, "%d.%d", &major, &minor) != 2)
{
versionValue = 0;
}
if(versionValue && (major < 2 || major == 2 && minor < 3))
{
compatibility = true;
}
// copy argsIn into args so it can be modified,
// in the process extract the DOC "documentation"
size_t size = argsIn.size();
std::vector<std::string> args;
bool foundDoc = false;
for(unsigned int j = 0; j < size; ++j)
{
if(foundDoc || argsIn[j] != "DOC" )
{
if(argsIn[j] == "ENV")
{
if(j+1 < size)
{
j++;
cmSystemTools::GetPath(args, argsIn[j].c_str());
}
}
else
{
args.push_back(argsIn[j]);
}
}
else
{
if(j+1 < size)
{
foundDoc = true;
this->VariableDocumentation = argsIn[j+1];
j++;
if(j >= size)
{
break;
}
}
}
}
this->VariableName = args[0];
if(this->CheckForVariableInCache())
{
this->AlreadyInCache = true;
return true;
}
this->AlreadyInCache = false;
std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_";
findRootPathVar += this->CMakePathName;
std::string rootPathMode = this->Makefile->GetSafeDefinition(findRootPathVar.c_str());
if (rootPathMode=="NEVER")
{
this->FindRootPathMode = RootPathModeNoRootPath;
}
else if (rootPathMode=="ONLY")
{
this->FindRootPathMode = RootPathModeOnlyRootPath;
}
else if (rootPathMode=="BOTH")
{
this->FindRootPathMode = RootPathModeBoth;
}
std::vector<std::string> userPaths;
std::string doc;
bool doingNames = true; // assume it starts with a name
bool doingPaths = false;
bool doingPathSuf = false;
bool newStyle = false;
for (unsigned int j = 1; j < args.size(); ++j)
{
if(args[j] == "NAMES")
{
doingNames = true;
newStyle = true;
doingPathSuf = false;
doingPaths = false;
}
else if (args[j] == "PATHS")
{
doingPaths = true;
newStyle = true;
doingNames = false;
doingPathSuf = false;
}
else if (args[j] == "PATH_SUFFIXES")
{
compatibility = false;
doingPathSuf = true;
newStyle = true;
doingNames = false;
doingPaths = false;
}
else if (args[j] == "NO_SYSTEM_PATH")
{
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoDefaultPath = true;
}
else if (args[j] == "NO_DEFAULT_PATH")
{
compatibility = false;
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoDefaultPath = true;
}
else if (args[j] == "NO_CMAKE_ENVIRONMENT_PATH")
{
compatibility = false;
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoCMakeEnvironmentPath = true;
}
else if (args[j] == "NO_CMAKE_PATH")
{
compatibility = false;
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoCMakePath = true;
}
else if (args[j] == "NO_SYSTEM_ENVIRONMENT_PATH")
{
compatibility = false;
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoSystemEnvironmentPath = true;
}
else if (args[j] == "NO_CMAKE_SYSTEM_PATH")
{
compatibility = false;
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoCMakeSystemPath = true;
}
else if (args[j] == "NO_CMAKE_FIND_ROOT_PATH")
{
compatibility = false;
this->FindRootPathMode = RootPathModeNoRootPath;
}
else if (args[j] == "ONLY_CMAKE_FIND_ROOT_PATH")
{
compatibility = false;
this->FindRootPathMode = RootPathModeOnlyRootPath;
}
else if (args[j] == "CMAKE_FIND_ROOT_PATH_BOTH")
{
compatibility = false;
this->FindRootPathMode = RootPathModeBoth;
}
else
{
if(doingNames)
{
this->Names.push_back(args[j]);
}
else if(doingPaths)
{
userPaths.push_back(args[j]);
}
else if(doingPathSuf)
{
this->SearchPathSuffixes.push_back(args[j]);
}
}
}
// Now that arguments have been parsed check the compatibility
// setting. If we need to be compatible with CMake 2.2 and earlier
// do not add the CMake system paths. It is safe to add the CMake
// environment paths and system environment paths because that
// existed in 2.2. It is safe to add the CMake user variable paths
// because the user or project has explicitly set them.
if(compatibility)
{
this->NoCMakeSystemPath = true;
}
if(this->VariableDocumentation.size() == 0)
{
this->VariableDocumentation = "Where can ";
if(this->Names.size() == 0)
{
this->VariableDocumentation += "the (unknown) library be found";
}
else if(this->Names.size() == 1)
{
this->VariableDocumentation += "the "
+ this->Names[0] + " library be found";
}
else
{
this->VariableDocumentation += "one of the " + this->Names[0];
for (unsigned int j = 1; j < this->Names.size() - 1; ++j)
{
this->VariableDocumentation += ", " + this->Names[j];
}
this->VariableDocumentation += " or "
+ this->Names[this->Names.size() - 1] + " libraries be found";
}
}
// look for old style
// FIND_*(VAR name path1 path2 ...)
if(!newStyle)
{
this->Names.clear(); // clear out any values in Names
this->Names.push_back(args[1]);
for(unsigned int j = 2; j < args.size(); ++j)
{
userPaths.push_back(args[j]);
}
}
this->ExpandPaths(userPaths);
this->HandleCMakeFindRootPath();
return true;
}
void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
{
// if NO Default paths was not specified add the
// standard search paths.
if(!this->NoDefaultPath)
{
if(this->SearchFrameworkFirst)
{
this->AddFrameWorkPaths();
}
if(this->SearchAppBundleFirst)
{
this->AddAppBundlePaths();
}
if(!this->NoCMakeEnvironmentPath &&
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
{
// Add CMAKE_*_PATH environment variables
this->AddEnvironmentVariables();
}
if(!this->NoCMakePath &&
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
{
// Add CMake varibles of the same name as the previous environment
// varibles CMAKE_*_PATH to be used most of the time with -D
// command line options
this->AddCMakeVariables();
}
if(!this->NoSystemEnvironmentPath &&
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
{
// add System environment PATH and (LIB or INCLUDE)
this->AddSystemEnvironmentVariables();
}
if(!this->NoCMakeSystemPath &&
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
{
// Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files
this->AddCMakeSystemVariables();
}
if(this->SearchAppBundleLast)
{
this->AddAppBundlePaths();
}
if(this->SearchFrameworkLast)
{
this->AddFrameWorkPaths();
}
}
std::vector<std::string> paths;
// add the paths specified in the FIND_* call
for(unsigned int i =0; i < userPaths.size(); ++i)
{
paths.push_back(userPaths[i]);
}
this->AddPaths(paths);
}
void cmFindBase::HandleCMakeFindRootPath()
{
if (this->FindRootPathMode == RootPathModeNoRootPath)
{
return;
}
const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH");
if ((rootPath == 0) || (strlen(rootPath) == 0))
{
return;
}
std::vector<std::string> prefixes;
cmSystemTools::ExpandListArgument(rootPath, prefixes);
std::vector<std::string> unprefixedPaths=this->SearchPaths;
this->SearchPaths.clear();
for (std::vector<std::string>::const_iterator prefixIt = prefixes.begin();
prefixIt != prefixes.end();
++prefixIt )
{
for (std::vector<std::string>::const_iterator it = unprefixedPaths.begin();
it != unprefixedPaths.end();
++it )
{
std::string prefixedDir=*prefixIt;
prefixedDir+=*it;
this->SearchPaths.push_back(prefixedDir);
}
}
if (this->FindRootPathMode == RootPathModeBoth)
{
this->AddPaths(unprefixedPaths);
}
}
void cmFindBase::AddEnvironmentVariables()
{
std::string var = "CMAKE_";
var += this->CMakePathName;
var += "_PATH";
std::vector<std::string> paths;
cmSystemTools::GetPath(paths, var.c_str());
if(this->SearchAppBundleLast)
{
cmSystemTools::GetPath(paths, "CMAKE_APPBUNDLE_PATH");
}
if(this->SearchFrameworkLast)
{
cmSystemTools::GetPath(paths, "CMAKE_FRAMEWORK_PATH");
}
this->AddPaths(paths);
}
void cmFindBase::AddFrameWorkPaths()
{
if(this->NoDefaultPath)
{
return;
}
std::vector<std::string> paths;
// first environment variables
if(!this->NoCMakeEnvironmentPath)
{
cmSystemTools::GetPath(paths, "CMAKE_FRAMEWORK_PATH");
}
// add cmake variables
if(!this->NoCMakePath)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
// AddCMakeSystemVariables
if(!this->NoCMakeSystemPath)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
this->AddPaths(paths);
}
void cmFindBase::AddPaths(std::vector<std::string> & paths)
{
// add suffixes and clean up paths
this->ExpandRegistryAndCleanPath(paths);
// add the paths to the search paths
this->SearchPaths.insert(this->SearchPaths.end(),
paths.begin(),
paths.end());
}
void cmFindBase::AddAppBundlePaths()
{
if(this->NoDefaultPath)
{
return;
}
std::vector<std::string> paths;
// first environment variables
if(!this->NoCMakeEnvironmentPath)
{
cmSystemTools::GetPath(paths, "CMAKE_APPBUNDLE_PATH");
}
// add cmake variables
if(!this->NoCMakePath)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
// AddCMakeSystemVariables
if(!this->NoCMakeSystemPath)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
this->AddPaths(paths);
}
void cmFindBase::AddCMakeVariables()
{
std::string var = "CMAKE_";
var += this->CMakePathName;
var += "_PATH";
std::vector<std::string> paths;
if(const char* path = this->Makefile->GetDefinition(var.c_str()))
{
cmSystemTools::ExpandListArgument(path, paths);
}
if(this->SearchAppBundleLast)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
if(this->SearchFrameworkLast)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
this->AddPaths(paths);
}
void cmFindBase::AddSystemEnvironmentVariables()
{
// Add LIB or INCLUDE
std::vector<std::string> paths;
if(this->EnvironmentPath.size())
{
cmSystemTools::GetPath(paths, this->EnvironmentPath.c_str());
}
// Add PATH
cmSystemTools::GetPath(paths);
this->AddPaths(paths);
}
void cmFindBase::AddCMakeSystemVariables()
{
std::string var = "CMAKE_SYSTEM_";
var += this->CMakePathName;
var += "_PATH";
std::vector<std::string> paths;
if(const char* path = this->Makefile->GetDefinition(var.c_str()))
{
cmSystemTools::ExpandListArgument(path, paths);
}
if(this->SearchAppBundleLast)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
if(this->SearchFrameworkLast)
{
if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
{
cmSystemTools::ExpandListArgument(path, paths);
}
}
this->AddPaths(paths);
}
void cmFindBase::ExpandRegistryAndCleanPath(std::vector<std::string>& paths)
{
std::vector<std::string> finalPath;
std::vector<std::string>::iterator i;
// glob and expand registry stuff from paths and put
// into finalPath
for(i = paths.begin();
i != paths.end(); ++i)
{
cmSystemTools::ExpandRegistryValues(*i);
cmSystemTools::GlobDirs(i->c_str(), finalPath);
}
// clear the path
paths.clear();
// convert all paths to unix slashes and add search path suffixes
// if there are any
for(i = finalPath.begin();
i != finalPath.end(); ++i)
{
cmSystemTools::ConvertToUnixSlashes(*i);
// copy each finalPath combined with SearchPathSuffixes
// to the SearchPaths ivar
for(std::vector<std::string>::iterator j =
this->SearchPathSuffixes.begin();
j != this->SearchPathSuffixes.end(); ++j)
{
std::string p = *i + std::string("/") + *j;
// add to all paths because the search path may be modified
// later with lib being replaced for lib64 which may exist
paths.push_back(p);
}
}
// now put the path without the path suffixes in the SearchPaths
for(i = finalPath.begin();
i != finalPath.end(); ++i)
{
// put all search paths in because it may later be replaced
// by lib64 stuff fixes bug 4009
paths.push_back(*i);
}
}
void cmFindBase::PrintFindStuff()
{
std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
std::cerr << "SearchFrameworkOnly: " << this->SearchFrameworkOnly << "\n";
std::cerr << "SearchFrameworkFirst: " << this->SearchFrameworkFirst << "\n";
std::cerr << "SearchAppBundleLast: " << this->SearchAppBundleLast << "\n";
std::cerr << "SearchAppBundleOnly: " << this->SearchAppBundleOnly << "\n";
std::cerr << "SearchAppBundleFirst: " << this->SearchAppBundleFirst << "\n";
std::cerr << "VariableName " << this->VariableName << "\n";
std::cerr << "VariableDocumentation "
<< this->VariableDocumentation << "\n";
std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";
std::cerr << "NoCMakeEnvironmentPath "
<< this->NoCMakeEnvironmentPath << "\n";
std::cerr << "NoCMakePath " << this->NoCMakePath << "\n";
std::cerr << "NoSystemEnvironmentPath "
<< this->NoSystemEnvironmentPath << "\n";
std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
std::cerr << "CMakePathName " << this->CMakePathName << "\n";
std::cerr << "Names ";
for(unsigned int i =0; i < this->Names.size(); ++i)
{
std::cerr << this->Names[i] << " ";
}
std::cerr << "\n";
std::cerr << "\n";
std::cerr << "SearchPathSuffixes ";
for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i)
{
std::cerr << this->SearchPathSuffixes[i] << "\n";
}
std::cerr << "\n";
std::cerr << "SearchPaths\n";
for(unsigned int i =0; i < this->SearchPaths.size(); ++i)
{
std::cerr << "[" << this->SearchPaths[i] << "]\n";
}
}
bool cmFindBase::CheckForVariableInCache()
{
if(const char* cacheValue =
this->Makefile->GetDefinition(this->VariableName.c_str()))
{
cmCacheManager::CacheIterator it =
this->Makefile->GetCacheManager()->
GetCacheIterator(this->VariableName.c_str());
bool found = !cmSystemTools::IsNOTFOUND(cacheValue);
bool cached = !it.IsAtEnd();
if(found)
{
// If the user specifies the entry on the command line without a
// type we should add the type and docstring but keep the
// original value. Tell the subclass implementations to do
// this.
if(cached && it.GetType() == cmCacheManager::UNINITIALIZED)
{
this->AlreadyInCacheWithoutMetaInfo = true;
}
return true;
}
else if(cached)
{
const char* hs = it.GetProperty("HELPSTRING");
this->VariableDocumentation = hs?hs:"(none)";
}
}
return false;
}
|