cmFindBase.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmFindBase.h"
  14. cmFindBase::cmFindBase()
  15. {
  16. this->AlreadyInCache = false;
  17. this->NoDefaultPath = false;
  18. this->NoCMakePath = false;
  19. this->NoCMakeEnvironmentPath = false;
  20. this->NoSystemEnvironmentPath = false;
  21. this->NoCMakeSystemPath = false;
  22. // default is to search frameworks first on apple
  23. #if defined(__APPLE__)
  24. this->SearchFrameworkFirst = true;
  25. this->SearchAppBundleFirst = true;
  26. #else
  27. this->SearchFrameworkFirst = false;
  28. this->SearchAppBundleFirst = false;
  29. #endif
  30. this->SearchFrameworkOnly = false;
  31. this->SearchFrameworkLast = false;
  32. this->SearchAppBundleOnly = false;
  33. this->SearchAppBundleLast = false;
  34. this->GenericDocumentation =
  35. " FIND_XXX(<VAR> name1 path1 path2 ...)\n"
  36. "This is the short-hand signature for the command that "
  37. "is sufficient in many cases. It is the same "
  38. "as FIND_XXX(<VAR> name1 PATHS path2 path2 ...)\n"
  39. " FIND_XXX(\n"
  40. " <VAR> \n"
  41. " name | NAMES name1 [name2 ...]\n"
  42. " PATHS path1 [path2 ... ENV var]\n"
  43. " [PATH_SUFFIXES suffix1 [suffix2 ...]]\n"
  44. " [DOC \"cache documentation string\"]\n"
  45. " [NO_DEFAULT_PATH]\n"
  46. " [NO_CMAKE_ENVIRONMENT_PATH]\n"
  47. " [NO_CMAKE_PATH]\n"
  48. " [NO_SYSTEM_ENVIRONMENT_PATH]\n"
  49. " [NO_CMAKE_SYSTEM_PATH]\n"
  50. " )\n"
  51. ""
  52. "This command is used to find a SEARCH_XXX_DESC. "
  53. "A cache entry named by <VAR> is created to store the result "
  54. "of this command. If nothing is found, the result will be "
  55. "<VAR>-NOTFOUND. The name of the SEARCH_XXX that "
  56. "is searched for is specified by the names listed "
  57. "after the NAMES argument. Additional search locations "
  58. "can be specified after the PATHS argument. If ENV var is "
  59. "found in the PATHS section the environment variable var "
  60. "will be read and converted from a system environment variable to "
  61. "a cmake style list of paths. For example ENV PATH would be a way "
  62. "to list the system path variable. The argument "
  63. "after DOC will be used for the documentation string in "
  64. "the cache. PATH_SUFFIXES can be used to give sub directories "
  65. "that will be appended to the search paths.\n"
  66. "If NO_DEFAULT_PATH is specified, then no additional paths are "
  67. "added to the search. "
  68. "If NO_DEFAULT_PATH is not specified, the search process is as follows:\n"
  69. "1. Search cmake specific environment variables. This "
  70. "can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n"
  71. ""
  72. " CMAKE_FRAMEWORK_PATH\n"
  73. " CMAKE_APPBUNDLE_PATH\n"
  74. " CMAKE_XXX_PATH\n"
  75. "2. Search cmake variables with the same names as "
  76. "the cmake specific environment variables. These "
  77. "are intended to be used on the command line with a "
  78. "-DVAR=value. This can be skipped if NO_CMAKE_PATH "
  79. "is passed.\n"
  80. ""
  81. " CMAKE_FRAMEWORK_PATH\n"
  82. " CMAKE_APPBUNDLE_PATH\n"
  83. " CMAKE_XXX_PATH\n"
  84. "3. Search the standard system environment variables. "
  85. "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.\n"
  86. " PATH\n"
  87. " XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE
  88. "4. Search cmake variables defined in the Platform files "
  89. "for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH "
  90. "is passed.\n"
  91. " CMAKE_SYSTEM_FRAMEWORK_PATH\n"
  92. " CMAKE_SYSTEM_APPBUNDLE_PATH\n"
  93. " CMAKE_SYSTEM_XXX_PATH\n"
  94. "5. Search the paths specified after PATHS or in the short-hand version "
  95. "of the command.\n"
  96. "On Darwin or systems supporting OSX Frameworks, the cmake variable"
  97. " CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:\n"
  98. " \"FIRST\" - Try to find frameworks before standard\n"
  99. " libraries or headers. This is the default on Darwin.\n"
  100. " \"LAST\" - Try to find frameworks after standard\n"
  101. " libraries or headers.\n"
  102. " \"ONLY\" - Only try to find frameworks.\n"
  103. " \"NEVER\". - Never try to find frameworks.\n"
  104. "On Darwin or systems supporting OSX Application Bundles, the cmake "
  105. "variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the "
  106. "following:\n"
  107. " \"FIRST\" - Try to find application bundles before standard\n"
  108. " programs. This is the default on Darwin.\n"
  109. " \"LAST\" - Try to find application bundles after standard\n"
  110. " programs.\n"
  111. " \"ONLY\" - Only try to find application bundles.\n"
  112. " \"NEVER\". - Never try to find application bundles.\n"
  113. "The reason the paths listed in the call to the command are searched "
  114. "last is that most users of CMake would expect things to be found "
  115. "first in the locations specified by their environment. Projects may "
  116. "override this behavior by simply calling the command twice:\n"
  117. " FIND_XXX(<VAR> NAMES name PATHS paths NO_DEFAULT_PATH)\n"
  118. " FIND_XXX(<VAR> NAMES name)\n"
  119. "Once one of these calls succeeds the result variable will be set "
  120. "and stored in the cache so that neither call will search again.";
  121. }
  122. bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
  123. {
  124. if(argsIn.size() < 2 )
  125. {
  126. this->SetError("called with incorrect number of arguments");
  127. return false;
  128. }
  129. std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK");
  130. if(ff == "NEVER")
  131. {
  132. this->SearchFrameworkLast = false;
  133. this->SearchFrameworkFirst = false;
  134. this->SearchFrameworkOnly = false;
  135. }
  136. else if (ff == "ONLY")
  137. {
  138. this->SearchFrameworkLast = false;
  139. this->SearchFrameworkFirst = false;
  140. this->SearchFrameworkOnly = true;
  141. }
  142. else if (ff == "FIRST")
  143. {
  144. this->SearchFrameworkLast = false;
  145. this->SearchFrameworkFirst = true;
  146. this->SearchFrameworkOnly = false;
  147. }
  148. else if (ff == "LAST")
  149. {
  150. this->SearchFrameworkLast = true;
  151. this->SearchFrameworkFirst = false;
  152. this->SearchFrameworkOnly = false;
  153. }
  154. std::string fab = this->Makefile->GetSafeDefinition("CMAKE_FIND_APPBUNDLE");
  155. if(fab == "NEVER")
  156. {
  157. this->SearchAppBundleLast = false;
  158. this->SearchAppBundleFirst = false;
  159. this->SearchAppBundleOnly = false;
  160. }
  161. else if (fab == "ONLY")
  162. {
  163. this->SearchAppBundleLast = false;
  164. this->SearchAppBundleFirst = false;
  165. this->SearchAppBundleOnly = true;
  166. }
  167. else if (fab == "FIRST")
  168. {
  169. this->SearchAppBundleLast = false;
  170. this->SearchAppBundleFirst = true;
  171. this->SearchAppBundleOnly = false;
  172. }
  173. else if (fab == "LAST")
  174. {
  175. this->SearchAppBundleLast = true;
  176. this->SearchAppBundleFirst = false;
  177. this->SearchAppBundleOnly = false;
  178. }
  179. // CMake versions below 2.3 did not search all these extra
  180. // locations. Preserve compatibility unless a modern argument is
  181. // passed.
  182. bool compatibility = false;
  183. const char* versionValue =
  184. this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
  185. int major = 0;
  186. int minor = 0;
  187. if(versionValue && sscanf(versionValue, "%d.%d", &major, &minor) != 2)
  188. {
  189. versionValue = 0;
  190. }
  191. if(versionValue && (major < 2 || major == 2 && minor < 3))
  192. {
  193. compatibility = true;
  194. }
  195. // copy argsIn into args so it can be modified,
  196. // in the process extract the DOC "documentation"
  197. size_t size = argsIn.size();
  198. std::vector<std::string> args;
  199. bool foundDoc = false;
  200. for(unsigned int j = 0; j < size; ++j)
  201. {
  202. if(foundDoc || argsIn[j] != "DOC" )
  203. {
  204. if(argsIn[j] == "ENV")
  205. {
  206. if(j+1 < size)
  207. {
  208. j++;
  209. cmSystemTools::GetPath(args, argsIn[j].c_str());
  210. }
  211. }
  212. else
  213. {
  214. args.push_back(argsIn[j]);
  215. }
  216. }
  217. else
  218. {
  219. if(j+1 < size)
  220. {
  221. foundDoc = true;
  222. this->VariableDocumentation = argsIn[j+1];
  223. j++;
  224. if(j >= size)
  225. {
  226. break;
  227. }
  228. }
  229. }
  230. }
  231. this->VariableName = args[0];
  232. if(this->CheckForVariableInCache())
  233. {
  234. this->AlreadyInCache = true;
  235. return true;
  236. }
  237. this->AlreadyInCache = false;
  238. std::vector<std::string> userPaths;
  239. std::string doc;
  240. bool doingNames = true; // assume it starts with a name
  241. bool doingPaths = false;
  242. bool doingPathSuf = false;
  243. bool newStyle = false;
  244. for (unsigned int j = 1; j < args.size(); ++j)
  245. {
  246. if(args[j] == "NAMES")
  247. {
  248. doingNames = true;
  249. newStyle = true;
  250. doingPathSuf = false;
  251. doingPaths = false;
  252. }
  253. else if (args[j] == "PATHS")
  254. {
  255. doingPaths = true;
  256. newStyle = true;
  257. doingNames = false;
  258. doingPathSuf = false;
  259. }
  260. else if (args[j] == "PATH_SUFFIXES")
  261. {
  262. compatibility = false;
  263. doingPathSuf = true;
  264. newStyle = true;
  265. doingNames = false;
  266. doingPaths = false;
  267. }
  268. else if (args[j] == "NO_SYSTEM_PATH")
  269. {
  270. doingPaths = false;
  271. doingPathSuf = false;
  272. doingNames = false;
  273. this->NoDefaultPath = true;
  274. }
  275. else if (args[j] == "NO_DEFAULT_PATH")
  276. {
  277. compatibility = false;
  278. doingPaths = false;
  279. doingPathSuf = false;
  280. doingNames = false;
  281. this->NoDefaultPath = true;
  282. }
  283. else if (args[j] == "NO_CMAKE_ENVIRONMENT_PATH")
  284. {
  285. compatibility = false;
  286. doingPaths = false;
  287. doingPathSuf = false;
  288. doingNames = false;
  289. this->NoCMakeEnvironmentPath = true;
  290. }
  291. else if (args[j] == "NO_CMAKE_PATH")
  292. {
  293. compatibility = false;
  294. doingPaths = false;
  295. doingPathSuf = false;
  296. doingNames = false;
  297. this->NoCMakePath = true;
  298. }
  299. else if (args[j] == "NO_SYSTEM_ENVIRONMENT_PATH")
  300. {
  301. compatibility = false;
  302. doingPaths = false;
  303. doingPathSuf = false;
  304. doingNames = false;
  305. this->NoSystemEnvironmentPath = true;
  306. }
  307. else if (args[j] == "NO_CMAKE_SYSTEM_PATH")
  308. {
  309. compatibility = false;
  310. doingPaths = false;
  311. doingPathSuf = false;
  312. doingNames = false;
  313. this->NoCMakeSystemPath = true;
  314. }
  315. else
  316. {
  317. if(doingNames)
  318. {
  319. this->Names.push_back(args[j]);
  320. }
  321. else if(doingPaths)
  322. {
  323. userPaths.push_back(args[j]);
  324. }
  325. else if(doingPathSuf)
  326. {
  327. this->SearchPathSuffixes.push_back(args[j]);
  328. }
  329. }
  330. }
  331. // Now that arguments have been parsed check the compatibility
  332. // setting. If we need to be compatible with CMake 2.2 and earlier
  333. // do not add the CMake system paths. It is safe to add the CMake
  334. // environment paths and system environment paths because that
  335. // existed in 2.2. It is safe to add the CMake user variable paths
  336. // because the user or project has explicitly set them.
  337. if(compatibility)
  338. {
  339. this->NoCMakeSystemPath = true;
  340. }
  341. if(this->VariableDocumentation.size() == 0)
  342. {
  343. this->VariableDocumentation = "Whare can ";
  344. if(this->Names.size() == 0)
  345. {
  346. this->VariableDocumentation += "the (unknown) library be found";
  347. }
  348. else if(this->Names.size() == 1)
  349. {
  350. this->VariableDocumentation += "the "
  351. + this->Names[0] + " library be found";
  352. }
  353. else
  354. {
  355. this->VariableDocumentation += "one of the " + this->Names[0];
  356. for (unsigned int j = 1; j < this->Names.size() - 1; ++j)
  357. {
  358. this->VariableDocumentation += ", " + this->Names[j];
  359. }
  360. this->VariableDocumentation += " or "
  361. + this->Names[this->Names.size() - 1] + " libraries be found";
  362. }
  363. }
  364. // look for old style
  365. // FIND_*(VAR name path1 path2 ...)
  366. if(!newStyle)
  367. {
  368. this->Names.clear(); // clear out any values in Names
  369. this->Names.push_back(args[1]);
  370. for(unsigned int j = 2; j < args.size(); ++j)
  371. {
  372. userPaths.push_back(args[j]);
  373. }
  374. }
  375. this->ExpandPaths(userPaths);
  376. return true;
  377. }
  378. void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
  379. {
  380. // if NO Default paths was not specified add the
  381. // standard search paths.
  382. if(!this->NoDefaultPath)
  383. {
  384. if(this->SearchFrameworkFirst)
  385. {
  386. this->AddFrameWorkPaths();
  387. }
  388. if(this->SearchAppBundleFirst)
  389. {
  390. this->AddAppBundlePaths();
  391. }
  392. if(!this->NoCMakeEnvironmentPath &&
  393. !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  394. {
  395. // Add CMAKE_*_PATH environment variables
  396. this->AddEnvironmentVairables();
  397. }
  398. if(!this->NoCMakePath &&
  399. !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  400. {
  401. // Add CMake varibles of the same name as the previous environment
  402. // varibles CMAKE_*_PATH to be used most of the time with -D
  403. // command line options
  404. this->AddCMakeVairables();
  405. }
  406. if(!this->NoSystemEnvironmentPath &&
  407. !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  408. {
  409. // add System environment PATH and (LIB or INCLUDE)
  410. this->AddSystemEnvironmentVairables();
  411. }
  412. if(!this->NoCMakeSystemPath &&
  413. !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  414. {
  415. // Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files
  416. this->AddCMakeSystemVariables();
  417. }
  418. if(this->SearchAppBundleLast)
  419. {
  420. this->AddAppBundlePaths();
  421. }
  422. if(this->SearchFrameworkLast)
  423. {
  424. this->AddFrameWorkPaths();
  425. }
  426. }
  427. // add the paths specified in the FIND_* call
  428. for(unsigned int i =0; i < userPaths.size(); ++i)
  429. {
  430. this->SearchPaths.push_back(userPaths[i]);
  431. }
  432. // clean things up
  433. this->ExpandRegistryAndCleanPath();
  434. }
  435. void cmFindBase::AddEnvironmentVairables()
  436. {
  437. std::string var = "CMAKE_";
  438. var += this->CMakePathName;
  439. var += "_PATH";
  440. cmSystemTools::GetPath(this->SearchPaths, var.c_str());
  441. if(this->SearchAppBundleLast)
  442. {
  443. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH");
  444. }
  445. if(this->SearchFrameworkLast)
  446. {
  447. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH");
  448. }
  449. }
  450. void cmFindBase::AddFrameWorkPaths()
  451. {
  452. if(this->NoDefaultPath)
  453. {
  454. return;
  455. }
  456. // first environment variables
  457. if(!this->NoCMakeEnvironmentPath)
  458. {
  459. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH");
  460. }
  461. // add cmake variables
  462. if(!this->NoCMakePath)
  463. {
  464. if(const char* path =
  465. this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
  466. {
  467. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  468. }
  469. }
  470. // AddCMakeSystemVariables
  471. if(!this->NoCMakeSystemPath)
  472. {
  473. if(const char* path =
  474. this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
  475. {
  476. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  477. }
  478. }
  479. }
  480. void cmFindBase::AddAppBundlePaths()
  481. {
  482. if(this->NoDefaultPath)
  483. {
  484. return;
  485. }
  486. // first environment variables
  487. if(!this->NoCMakeEnvironmentPath)
  488. {
  489. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH");
  490. }
  491. // add cmake variables
  492. if(!this->NoCMakePath)
  493. {
  494. if(const char* path =
  495. this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
  496. {
  497. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  498. }
  499. }
  500. // AddCMakeSystemVariables
  501. if(!this->NoCMakeSystemPath)
  502. {
  503. if(const char* path =
  504. this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
  505. {
  506. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  507. }
  508. }
  509. }
  510. void cmFindBase::AddCMakeVairables()
  511. {
  512. std::string var = "CMAKE_";
  513. var += this->CMakePathName;
  514. var += "_PATH";
  515. if(const char* path = this->Makefile->GetDefinition(var.c_str()))
  516. {
  517. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  518. }
  519. if(this->SearchAppBundleLast)
  520. {
  521. if(const char* path =
  522. this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
  523. {
  524. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  525. }
  526. }
  527. if(this->SearchFrameworkLast)
  528. {
  529. if(const char* path =
  530. this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
  531. {
  532. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  533. }
  534. }
  535. }
  536. void cmFindBase::AddSystemEnvironmentVairables()
  537. {
  538. // Add LIB or INCLUDE
  539. if(this->EnvironmentPath.size())
  540. {
  541. cmSystemTools::GetPath(this->SearchPaths, this->EnvironmentPath.c_str());
  542. }
  543. // Add PATH
  544. cmSystemTools::GetPath(this->SearchPaths);
  545. }
  546. void cmFindBase::AddCMakeSystemVariables()
  547. {
  548. std::string var = "CMAKE_SYSTEM_";
  549. var += this->CMakePathName;
  550. var += "_PATH";
  551. if(const char* path = this->Makefile->GetDefinition(var.c_str()))
  552. {
  553. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  554. }
  555. if(this->SearchAppBundleLast)
  556. {
  557. if(const char* path =
  558. this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
  559. {
  560. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  561. }
  562. }
  563. if(this->SearchFrameworkLast)
  564. {
  565. if(const char* path =
  566. this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
  567. {
  568. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  569. }
  570. }
  571. }
  572. void cmFindBase::ExpandRegistryAndCleanPath()
  573. {
  574. std::vector<std::string> finalPath;
  575. std::vector<std::string>::iterator i;
  576. for(i = this->SearchPaths.begin();
  577. i != this->SearchPaths.end(); ++i)
  578. {
  579. cmSystemTools::ExpandRegistryValues(*i);
  580. cmSystemTools::GlobDirs(i->c_str(), finalPath);
  581. }
  582. this->SearchPaths.clear();
  583. // convert all paths to unix slashes
  584. for(i = finalPath.begin();
  585. i != finalPath.end(); ++i)
  586. {
  587. cmSystemTools::ConvertToUnixSlashes(*i);
  588. // copy each finalPath combined with SearchPathSuffixes
  589. // to the SearchPaths ivar
  590. for(std::vector<std::string>::iterator j =
  591. this->SearchPathSuffixes.begin();
  592. j != this->SearchPathSuffixes.end(); ++j)
  593. {
  594. std::string p = *i + std::string("/") + *j;
  595. if(cmSystemTools::FileIsDirectory(p.c_str()))
  596. {
  597. this->SearchPaths.push_back(p);
  598. }
  599. }
  600. }
  601. // now put the path without the path suffixes in the SearchPaths
  602. for(i = finalPath.begin();
  603. i != finalPath.end(); ++i)
  604. {
  605. if(cmSystemTools::FileIsDirectory(i->c_str()))
  606. {
  607. this->SearchPaths.push_back(*i);
  608. }
  609. }
  610. }
  611. void cmFindBase::PrintFindStuff()
  612. {
  613. std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
  614. std::cerr << "SearchFrameworkOnly: " << this->SearchFrameworkOnly << "\n";
  615. std::cerr << "SearchFrameworkFirst: " << this->SearchFrameworkFirst << "\n";
  616. std::cerr << "SearchAppBundleLast: " << this->SearchAppBundleLast << "\n";
  617. std::cerr << "SearchAppBundleOnly: " << this->SearchAppBundleOnly << "\n";
  618. std::cerr << "SearchAppBundleFirst: " << this->SearchAppBundleFirst << "\n";
  619. std::cerr << "VariableName " << this->VariableName << "\n";
  620. std::cerr << "VariableDocumentation "
  621. << this->VariableDocumentation << "\n";
  622. std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";
  623. std::cerr << "NoCMakeEnvironmentPath "
  624. << this->NoCMakeEnvironmentPath << "\n";
  625. std::cerr << "NoCMakePath " << this->NoCMakePath << "\n";
  626. std::cerr << "NoSystemEnvironmentPath "
  627. << this->NoSystemEnvironmentPath << "\n";
  628. std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
  629. std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
  630. std::cerr << "CMakePathName " << this->CMakePathName << "\n";
  631. std::cerr << "Names ";
  632. for(unsigned int i =0; i < this->Names.size(); ++i)
  633. {
  634. std::cerr << this->Names[i] << " ";
  635. }
  636. std::cerr << "\n";
  637. std::cerr << "\n";
  638. std::cerr << "SearchPathSuffixes ";
  639. for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i)
  640. {
  641. std::cerr << this->SearchPathSuffixes[i] << "\n";
  642. }
  643. std::cerr << "\n";
  644. std::cerr << "SearchPaths\n";
  645. for(unsigned int i =0; i < this->SearchPaths.size(); ++i)
  646. {
  647. std::cerr << "[" << this->SearchPaths[i] << "]\n";
  648. }
  649. }
  650. bool cmFindBase::CheckForVariableInCache()
  651. {
  652. const char* cacheValue
  653. = this->Makefile->GetDefinition(this->VariableName.c_str());
  654. if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
  655. {
  656. return true;
  657. }
  658. if(cacheValue)
  659. {
  660. cmCacheManager::CacheIterator it =
  661. this->Makefile->GetCacheManager()->
  662. GetCacheIterator(this->VariableName.c_str());
  663. if(!it.IsAtEnd())
  664. {
  665. const char* hs = it.GetProperty("HELPSTRING");
  666. this->VariableDocumentation = hs?hs:"(none)";
  667. }
  668. }
  669. return false;
  670. }