cmFindBase.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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 variable"
  105. " CMAKE_FIND_APPBUNDLE can be set to empty or one of the following:\n"
  106. " \"FIRST\" - Try to find application bundles before standard\n"
  107. " programs. This is the default on Darwin.\n"
  108. " \"LAST\" - Try to find application bundles after standard\n"
  109. " programs.\n"
  110. " \"ONLY\" - Only try to find application bundles.\n"
  111. " \"NEVER\". - Never try to find application bundles.\n"
  112. "The reason the paths listed in the call to the command are searched "
  113. "last is that most users of CMake would expect things to be found "
  114. "first in the locations specified by their environment. Projects may "
  115. "override this behavior by simply calling the command twice:\n"
  116. " FIND_XXX(<VAR> NAMES name PATHS paths NO_DEFAULT_PATH)\n"
  117. " FIND_XXX(<VAR> NAMES name)\n"
  118. "Once one of these calls succeeds the result variable will be set "
  119. "and stored in the cache so that neither call will search again.";
  120. }
  121. bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
  122. {
  123. if(argsIn.size() < 2 )
  124. {
  125. this->SetError("called with incorrect number of arguments");
  126. return false;
  127. }
  128. std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK");
  129. if(ff == "NEVER")
  130. {
  131. this->SearchFrameworkLast = false;
  132. this->SearchFrameworkFirst = false;
  133. this->SearchFrameworkOnly = false;
  134. }
  135. else if (ff == "ONLY")
  136. {
  137. this->SearchFrameworkLast = false;
  138. this->SearchFrameworkFirst = false;
  139. this->SearchFrameworkOnly = true;
  140. }
  141. else if (ff == "FIRST")
  142. {
  143. this->SearchFrameworkLast = false;
  144. this->SearchFrameworkFirst = true;
  145. this->SearchFrameworkOnly = false;
  146. }
  147. else if (ff == "LAST")
  148. {
  149. this->SearchFrameworkLast = true;
  150. this->SearchFrameworkFirst = false;
  151. this->SearchFrameworkOnly = false;
  152. }
  153. std::string fab = this->Makefile->GetSafeDefinition("CMAKE_FIND_APPBUNDLE");
  154. if(fab == "NEVER")
  155. {
  156. this->SearchAppBundleLast = false;
  157. this->SearchAppBundleFirst = false;
  158. this->SearchAppBundleOnly = false;
  159. }
  160. else if (fab == "ONLY")
  161. {
  162. this->SearchAppBundleLast = false;
  163. this->SearchAppBundleFirst = false;
  164. this->SearchAppBundleOnly = true;
  165. }
  166. else if (fab == "FIRST")
  167. {
  168. this->SearchAppBundleLast = false;
  169. this->SearchAppBundleFirst = true;
  170. this->SearchAppBundleOnly = false;
  171. }
  172. else if (fab == "LAST")
  173. {
  174. this->SearchAppBundleLast = true;
  175. this->SearchAppBundleFirst = false;
  176. this->SearchAppBundleOnly = false;
  177. }
  178. // CMake versions below 2.3 did not search all these extra
  179. // locations. Preserve compatibility unless a modern argument is
  180. // passed.
  181. bool compatibility = false;
  182. const char* versionValue =
  183. this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
  184. int major = 0;
  185. int minor = 0;
  186. if(versionValue && sscanf(versionValue, "%d.%d", &major, &minor) != 2)
  187. {
  188. versionValue = 0;
  189. }
  190. if(versionValue && (major < 2 || major == 2 && minor < 3))
  191. {
  192. compatibility = true;
  193. }
  194. // copy argsIn into args so it can be modified,
  195. // in the process extract the DOC "documentation"
  196. size_t size = argsIn.size();
  197. std::vector<std::string> args;
  198. bool foundDoc = false;
  199. for(unsigned int j = 0; j < size; ++j)
  200. {
  201. if(foundDoc || argsIn[j] != "DOC" )
  202. {
  203. if(argsIn[j] == "ENV")
  204. {
  205. if(j+1 < size)
  206. {
  207. j++;
  208. cmSystemTools::GetPath(args, argsIn[j].c_str());
  209. }
  210. }
  211. else
  212. {
  213. args.push_back(argsIn[j]);
  214. }
  215. }
  216. else
  217. {
  218. if(j+1 < size)
  219. {
  220. foundDoc = true;
  221. this->VariableDocumentation = argsIn[j+1];
  222. j++;
  223. if(j >= size)
  224. {
  225. break;
  226. }
  227. }
  228. }
  229. }
  230. this->VariableName = args[0];
  231. if(this->CheckForVariableInCache())
  232. {
  233. this->AlreadyInCache = true;
  234. return true;
  235. }
  236. this->AlreadyInCache = false;
  237. std::vector<std::string> userPaths;
  238. std::string doc;
  239. bool doingNames = true; // assume it starts with a name
  240. bool doingPaths = false;
  241. bool doingPathSuf = false;
  242. bool newStyle = false;
  243. for (unsigned int j = 1; j < args.size(); ++j)
  244. {
  245. if(args[j] == "NAMES")
  246. {
  247. doingNames = true;
  248. newStyle = true;
  249. doingPathSuf = false;
  250. doingPaths = false;
  251. }
  252. else if (args[j] == "PATHS")
  253. {
  254. doingPaths = true;
  255. newStyle = true;
  256. doingNames = false;
  257. doingPathSuf = false;
  258. }
  259. else if (args[j] == "PATH_SUFFIXES")
  260. {
  261. compatibility = false;
  262. doingPathSuf = true;
  263. newStyle = true;
  264. doingNames = false;
  265. doingPaths = false;
  266. }
  267. else if (args[j] == "NO_SYSTEM_PATH")
  268. {
  269. doingPaths = false;
  270. doingPathSuf = false;
  271. doingNames = false;
  272. this->NoDefaultPath = true;
  273. }
  274. else if (args[j] == "NO_DEFAULT_PATH")
  275. {
  276. compatibility = false;
  277. doingPaths = false;
  278. doingPathSuf = false;
  279. doingNames = false;
  280. this->NoDefaultPath = true;
  281. }
  282. else if (args[j] == "NO_CMAKE_ENVIRONMENT_PATH")
  283. {
  284. compatibility = false;
  285. doingPaths = false;
  286. doingPathSuf = false;
  287. doingNames = false;
  288. this->NoCMakeEnvironmentPath = true;
  289. }
  290. else if (args[j] == "NO_CMAKE_PATH")
  291. {
  292. compatibility = false;
  293. doingPaths = false;
  294. doingPathSuf = false;
  295. doingNames = false;
  296. this->NoCMakePath = true;
  297. }
  298. else if (args[j] == "NO_SYSTEM_ENVIRONMENT_PATH")
  299. {
  300. compatibility = false;
  301. doingPaths = false;
  302. doingPathSuf = false;
  303. doingNames = false;
  304. this->NoSystemEnvironmentPath = true;
  305. }
  306. else if (args[j] == "NO_CMAKE_SYSTEM_PATH")
  307. {
  308. compatibility = false;
  309. doingPaths = false;
  310. doingPathSuf = false;
  311. doingNames = false;
  312. this->NoCMakeSystemPath = true;
  313. }
  314. else
  315. {
  316. if(doingNames)
  317. {
  318. this->Names.push_back(args[j]);
  319. }
  320. else if(doingPaths)
  321. {
  322. userPaths.push_back(args[j]);
  323. }
  324. else if(doingPathSuf)
  325. {
  326. this->SearchPathSuffixes.push_back(args[j]);
  327. }
  328. }
  329. }
  330. // Now that arguments have been parsed check the compatibility
  331. // setting. If we need to be compatible with CMake 2.2 and earlier
  332. // do not add the CMake system paths. It is safe to add the CMake
  333. // environment paths and system environment paths because that
  334. // existed in 2.2. It is safe to add the CMake user variable paths
  335. // because the user or project has explicitly set them.
  336. if(compatibility)
  337. {
  338. this->NoCMakeSystemPath = true;
  339. }
  340. if(this->VariableDocumentation.size() == 0)
  341. {
  342. this->VariableDocumentation = "Whare can ";
  343. if(this->Names.size() == 0)
  344. {
  345. this->VariableDocumentation += "the (unknown) library be found";
  346. }
  347. else if(this->Names.size() == 1)
  348. {
  349. this->VariableDocumentation += "the " + this->Names[0] + " library be found";
  350. }
  351. else
  352. {
  353. this->VariableDocumentation += "one of the " + this->Names[0];
  354. for (unsigned int j = 1; j < this->Names.size() - 1; ++j)
  355. {
  356. this->VariableDocumentation += ", " + this->Names[j];
  357. }
  358. this->VariableDocumentation += " or " + this->Names[this->Names.size() - 1] + " libraries be found";
  359. }
  360. }
  361. // look for old style
  362. // FIND_*(VAR name path1 path2 ...)
  363. if(!newStyle)
  364. {
  365. this->Names.clear(); // clear out any values in Names
  366. this->Names.push_back(args[1]);
  367. for(unsigned int j = 2; j < args.size(); ++j)
  368. {
  369. userPaths.push_back(args[j]);
  370. }
  371. }
  372. this->ExpandPaths(userPaths);
  373. return true;
  374. }
  375. void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
  376. {
  377. // if NO Default paths was not specified add the
  378. // standard search paths.
  379. if(!this->NoDefaultPath)
  380. {
  381. if(this->SearchFrameworkFirst)
  382. {
  383. this->AddFrameWorkPaths();
  384. }
  385. if(this->SearchAppBundleFirst)
  386. {
  387. this->AddAppBundlePaths();
  388. }
  389. if(!this->NoCMakeEnvironmentPath && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  390. {
  391. // Add CMAKE_*_PATH environment variables
  392. this->AddEnvironmentVairables();
  393. }
  394. if(!this->NoCMakePath && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  395. {
  396. // Add CMake varibles of the same name as the previous environment
  397. // varibles CMAKE_*_PATH to be used most of the time with -D
  398. // command line options
  399. this->AddCMakeVairables();
  400. }
  401. if(!this->NoSystemEnvironmentPath && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  402. {
  403. // add System environment PATH and (LIB or INCLUDE)
  404. this->AddSystemEnvironmentVairables();
  405. }
  406. if(!this->NoCMakeSystemPath && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
  407. {
  408. // Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files
  409. this->AddCMakeSystemVariables();
  410. }
  411. if(this->SearchAppBundleLast)
  412. {
  413. this->AddAppBundlePaths();
  414. }
  415. if(this->SearchFrameworkLast)
  416. {
  417. this->AddFrameWorkPaths();
  418. }
  419. }
  420. // add the paths specified in the FIND_* call
  421. for(unsigned int i =0; i < userPaths.size(); ++i)
  422. {
  423. this->SearchPaths.push_back(userPaths[i]);
  424. }
  425. // clean things up
  426. this->ExpandRegistryAndCleanPath();
  427. }
  428. void cmFindBase::AddEnvironmentVairables()
  429. {
  430. std::string var = "CMAKE_";
  431. var += this->CMakePathName;
  432. var += "_PATH";
  433. cmSystemTools::GetPath(this->SearchPaths, var.c_str());
  434. if(this->SearchAppBundleLast)
  435. {
  436. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH");
  437. }
  438. if(this->SearchFrameworkLast)
  439. {
  440. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH");
  441. }
  442. }
  443. void cmFindBase::AddFrameWorkPaths()
  444. {
  445. if(this->NoDefaultPath)
  446. {
  447. return;
  448. }
  449. // first environment variables
  450. if(!this->NoCMakeEnvironmentPath)
  451. {
  452. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH");
  453. }
  454. // add cmake variables
  455. if(!this->NoCMakePath)
  456. {
  457. if(const char* path =
  458. this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
  459. {
  460. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  461. }
  462. }
  463. // AddCMakeSystemVariables
  464. if(!this->NoCMakeSystemPath)
  465. {
  466. if(const char* path =
  467. this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
  468. {
  469. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  470. }
  471. }
  472. }
  473. void cmFindBase::AddAppBundlePaths()
  474. {
  475. if(this->NoDefaultPath)
  476. {
  477. return;
  478. }
  479. // first environment variables
  480. if(!this->NoCMakeEnvironmentPath)
  481. {
  482. cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH");
  483. }
  484. // add cmake variables
  485. if(!this->NoCMakePath)
  486. {
  487. if(const char* path =
  488. this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
  489. {
  490. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  491. }
  492. }
  493. // AddCMakeSystemVariables
  494. if(!this->NoCMakeSystemPath)
  495. {
  496. if(const char* path =
  497. this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
  498. {
  499. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  500. }
  501. }
  502. }
  503. void cmFindBase::AddCMakeVairables()
  504. {
  505. std::string var = "CMAKE_";
  506. var += this->CMakePathName;
  507. var += "_PATH";
  508. if(const char* path = this->Makefile->GetDefinition(var.c_str()))
  509. {
  510. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  511. }
  512. if(this->SearchAppBundleLast)
  513. {
  514. if(const char* path =
  515. this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
  516. {
  517. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  518. }
  519. }
  520. if(this->SearchFrameworkLast)
  521. {
  522. if(const char* path =
  523. this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
  524. {
  525. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  526. }
  527. }
  528. }
  529. void cmFindBase::AddSystemEnvironmentVairables()
  530. {
  531. // Add LIB or INCLUDE
  532. if(this->EnvironmentPath.size())
  533. {
  534. cmSystemTools::GetPath(this->SearchPaths, this->EnvironmentPath.c_str());
  535. }
  536. // Add PATH
  537. cmSystemTools::GetPath(this->SearchPaths);
  538. }
  539. void cmFindBase::AddCMakeSystemVariables()
  540. {
  541. std::string var = "CMAKE_SYSTEM_";
  542. var += this->CMakePathName;
  543. var += "_PATH";
  544. if(const char* path = this->Makefile->GetDefinition(var.c_str()))
  545. {
  546. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  547. }
  548. if(this->SearchAppBundleLast)
  549. {
  550. if(const char* path = this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
  551. {
  552. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  553. }
  554. }
  555. if(this->SearchFrameworkLast)
  556. {
  557. if(const char* path = this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
  558. {
  559. cmSystemTools::ExpandListArgument(path, this->SearchPaths);
  560. }
  561. }
  562. }
  563. void cmFindBase::ExpandRegistryAndCleanPath()
  564. {
  565. std::vector<std::string> finalPath;
  566. std::vector<std::string>::iterator i;
  567. for(i = this->SearchPaths.begin();
  568. i != this->SearchPaths.end(); ++i)
  569. {
  570. cmSystemTools::ExpandRegistryValues(*i);
  571. cmSystemTools::GlobDirs(i->c_str(), finalPath);
  572. }
  573. this->SearchPaths.clear();
  574. // convert all paths to unix slashes
  575. for(i = finalPath.begin();
  576. i != finalPath.end(); ++i)
  577. {
  578. cmSystemTools::ConvertToUnixSlashes(*i);
  579. // copy each finalPath combined with SearchPathSuffixes
  580. // to the SearchPaths ivar
  581. for(std::vector<std::string>::iterator j = this->SearchPathSuffixes.begin();
  582. j != this->SearchPathSuffixes.end(); ++j)
  583. {
  584. std::string p = *i + std::string("/") + *j;
  585. if(cmSystemTools::FileIsDirectory(p.c_str()))
  586. {
  587. this->SearchPaths.push_back(p);
  588. }
  589. }
  590. }
  591. // now put the path without the path suffixes in the SearchPaths
  592. for(i = finalPath.begin();
  593. i != finalPath.end(); ++i)
  594. {
  595. if(cmSystemTools::FileIsDirectory(i->c_str()))
  596. {
  597. this->SearchPaths.push_back(*i);
  598. }
  599. }
  600. }
  601. void cmFindBase::PrintFindStuff()
  602. {
  603. std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
  604. std::cerr << "SearchFrameworkOnly: " << this->SearchFrameworkOnly << "\n";
  605. std::cerr << "SearchFrameworkFirst: " << this->SearchFrameworkFirst << "\n";
  606. std::cerr << "SearchAppBundleLast: " << this->SearchAppBundleLast << "\n";
  607. std::cerr << "SearchAppBundleOnly: " << this->SearchAppBundleOnly << "\n";
  608. std::cerr << "SearchAppBundleFirst: " << this->SearchAppBundleFirst << "\n";
  609. std::cerr << "VariableName " << this->VariableName << "\n";
  610. std::cerr << "VariableDocumentation " << this->VariableDocumentation << "\n";
  611. std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";
  612. std::cerr << "NoCMakeEnvironmentPath " << this->NoCMakeEnvironmentPath << "\n";
  613. std::cerr << "NoCMakePath " << this->NoCMakePath << "\n";
  614. std::cerr << "NoSystemEnvironmentPath " << this->NoSystemEnvironmentPath << "\n";
  615. std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
  616. std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
  617. std::cerr << "CMakePathName " << this->CMakePathName << "\n";
  618. std::cerr << "Names ";
  619. for(unsigned int i =0; i < this->Names.size(); ++i)
  620. {
  621. std::cerr << this->Names[i] << " ";
  622. }
  623. std::cerr << "\n";
  624. std::cerr << "\n";
  625. std::cerr << "SearchPathSuffixes ";
  626. for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i)
  627. {
  628. std::cerr << this->SearchPathSuffixes[i] << "\n";
  629. }
  630. std::cerr << "\n";
  631. std::cerr << "SearchPaths\n";
  632. for(unsigned int i =0; i < this->SearchPaths.size(); ++i)
  633. {
  634. std::cerr << "[" << this->SearchPaths[i] << "]\n";
  635. }
  636. }
  637. bool cmFindBase::CheckForVariableInCache()
  638. {
  639. const char* cacheValue
  640. = this->Makefile->GetDefinition(this->VariableName.c_str());
  641. if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
  642. {
  643. return true;
  644. }
  645. if(cacheValue)
  646. {
  647. cmCacheManager::CacheIterator it =
  648. this->Makefile->GetCacheManager()->GetCacheIterator(this->VariableName.c_str());
  649. if(!it.IsAtEnd())
  650. {
  651. const char* hs = it.GetProperty("HELPSTRING");
  652. this->VariableDocumentation = hs?hs:"(none)";
  653. }
  654. }
  655. return false;
  656. }