cmMakefile.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  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. #ifndef cmMakefile_h
  14. #define cmMakefile_h
  15. #include "cmData.h"
  16. #include "cmSystemTools.h"
  17. #include "cmTarget.h"
  18. #include "cmListFileCache.h"
  19. #include "cmCacheManager.h"
  20. #include "cmPropertyMap.h"
  21. #if defined(CMAKE_BUILD_WITH_CMAKE)
  22. #include "cmSourceGroup.h"
  23. #endif
  24. #include <cmsys/RegularExpression.hxx>
  25. class cmFunctionBlocker;
  26. class cmCommand;
  27. class cmInstallGenerator;
  28. class cmLocalGenerator;
  29. class cmMakeDepend;
  30. class cmSourceFile;
  31. class cmTest;
  32. class cmVariableWatch;
  33. class cmake;
  34. /** \class cmMakefile
  35. * \brief Process the input CMakeLists.txt file.
  36. *
  37. * Process and store into memory the input CMakeLists.txt file.
  38. * Each CMakeLists.txt file is parsed and the commands found there
  39. * are added into the build process.
  40. */
  41. class cmMakefile
  42. {
  43. public:
  44. /**
  45. * Return the major and minor version of the cmake that
  46. * was used to write the currently loaded cache, note
  47. * this method will not work before the cache is loaded.
  48. */
  49. unsigned int GetCacheMajorVersion();
  50. unsigned int GetCacheMinorVersion();
  51. /**
  52. * Construct an empty makefile.
  53. */
  54. cmMakefile();
  55. cmMakefile(const cmMakefile& mf);
  56. /**
  57. * Destructor.
  58. */
  59. ~cmMakefile();
  60. /**
  61. * Read and parse a CMakeLists.txt file.
  62. */
  63. bool ReadListFile(const char* listfile,
  64. const char* external= 0,
  65. std::string* fullPath= 0);
  66. /**
  67. * Add a function blocker to this makefile
  68. */
  69. void AddFunctionBlocker(cmFunctionBlocker *fb)
  70. { this->FunctionBlockers.push_back(fb);}
  71. void RemoveFunctionBlocker(cmFunctionBlocker *fb)
  72. { this->FunctionBlockers.remove(fb);}
  73. void RemoveFunctionBlocker(const cmListFileFunction& lff);
  74. /**
  75. * Add file to the written file list. These file should not be in the list
  76. * of dependencies because they cause infinite loops.
  77. */
  78. void AddWrittenFile(const char* file);
  79. bool HasWrittenFile(const char* file);
  80. /**
  81. * Check if there are any infinite loops
  82. */
  83. bool CheckInfiniteLoops();
  84. /**
  85. * Try running cmake and building a file. This is used for dynalically
  86. * loaded commands, not as part of the usual build process.
  87. */
  88. int TryCompile(const char *srcdir, const char *bindir,
  89. const char *projectName, const char *targetName,
  90. const std::vector<std::string> *cmakeArgs,
  91. std::string *output);
  92. /**
  93. * Specify the makefile generator. This is platform/compiler
  94. * dependent, although the interface is through a generic
  95. * superclass.
  96. */
  97. void SetLocalGenerator(cmLocalGenerator*);
  98. ///! Get the current makefile generator.
  99. cmLocalGenerator* GetLocalGenerator()
  100. { return this->LocalGenerator;}
  101. /**
  102. * Perform FinalPass, Library dependency analysis etc before output of the
  103. * makefile.
  104. */
  105. void ConfigureFinalPass();
  106. /**
  107. * run the final pass on all commands.
  108. */
  109. void FinalPass();
  110. /**
  111. * Print the object state to std::cout.
  112. */
  113. void Print();
  114. /** Add a custom command to the build. */
  115. void AddCustomCommandToTarget(const char* target,
  116. const std::vector<std::string>& depends,
  117. const cmCustomCommandLines& commandLines,
  118. cmTarget::CustomCommandType type,
  119. const char* comment, const char* workingDir,
  120. bool escapeOldStyle = true);
  121. void AddCustomCommandToOutput(const std::vector<std::string>& outputs,
  122. const std::vector<std::string>& depends,
  123. const char* main_dependency,
  124. const cmCustomCommandLines& commandLines,
  125. const char* comment, const char* workingDir,
  126. bool replace = false,
  127. bool escapeOldStyle = true);
  128. void AddCustomCommandToOutput(const char* output,
  129. const std::vector<std::string>& depends,
  130. const char* main_dependency,
  131. const cmCustomCommandLines& commandLines,
  132. const char* comment, const char* workingDir,
  133. bool replace = false,
  134. bool escapeOldStyle = true);
  135. void AddCustomCommandOldStyle(const char* target,
  136. const std::vector<std::string>& outputs,
  137. const std::vector<std::string>& depends,
  138. const char* source,
  139. const cmCustomCommandLines& commandLines,
  140. const char* comment);
  141. /**
  142. * Add a define flag to the build.
  143. */
  144. void AddDefineFlag(const char* definition);
  145. void RemoveDefineFlag(const char* definition);
  146. cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name, bool isImported);
  147. /**
  148. * Add an executable to the build.
  149. */
  150. cmTarget* AddExecutable(const char *exename,
  151. const std::vector<std::string> &srcs,
  152. bool excludeFromAll = false);
  153. /**
  154. * Add a utility to the build. A utiltity target is a command that
  155. * is run every time the target is built.
  156. */
  157. void AddUtilityCommand(const char* utilityName, bool excludeFromAll,
  158. const std::vector<std::string>& depends,
  159. const char* workingDirectory,
  160. const char* command,
  161. const char* arg1=0,
  162. const char* arg2=0,
  163. const char* arg3=0,
  164. const char* arg4=0);
  165. void AddUtilityCommand(const char* utilityName, bool excludeFromAll,
  166. const char* workingDirectory,
  167. const std::vector<std::string>& depends,
  168. const cmCustomCommandLines& commandLines,
  169. bool escapeOldStyle = true,
  170. const char* comment = 0);
  171. /**
  172. * Add a link library to the build.
  173. */
  174. void AddLinkLibrary(const char*);
  175. void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
  176. void AddLinkLibraryForTarget(const char *tgt, const char*,
  177. cmTarget::LinkLibraryType type);
  178. void AddLinkDirectoryForTarget(const char *tgt, const char* d);
  179. /**
  180. * Add a link directory to the build.
  181. */
  182. void AddLinkDirectory(const char*);
  183. /**
  184. * Get the list of link directories
  185. */
  186. std::vector<std::string>& GetLinkDirectories()
  187. {
  188. return this->LinkDirectories;
  189. }
  190. const std::vector<std::string>& GetLinkDirectories() const
  191. {
  192. return this->LinkDirectories;
  193. }
  194. void SetLinkDirectories(const std::vector<std::string>& vec)
  195. {
  196. this->LinkDirectories = vec;
  197. }
  198. /**
  199. * Add a subdirectory to the build.
  200. */
  201. void AddSubDirectory(const char*, bool excludeFromAll=false,
  202. bool preorder = false);
  203. void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir,
  204. bool excludeFromAll, bool preorder,
  205. bool immediate);
  206. /**
  207. * Configure a subdirectory
  208. */
  209. void ConfigureSubDirectory(cmLocalGenerator *);
  210. /**
  211. * Add an include directory to the build.
  212. */
  213. void AddIncludeDirectory(const char*, bool before = false);
  214. /**
  215. * Add a variable definition to the build. This variable
  216. * can be used in CMake to refer to lists, directories, etc.
  217. */
  218. void AddDefinition(const char* name, const char* value);
  219. ///! Add a definition to this makefile and the global cmake cache.
  220. void AddCacheDefinition(const char* name, const char* value,
  221. const char* doc,
  222. cmCacheManager::CacheEntryType type);
  223. /**
  224. * Add bool variable definition to the build.
  225. */
  226. void AddDefinition(const char* name, bool);
  227. ///! Add a definition to this makefile and the global cmake cache.
  228. void AddCacheDefinition(const char* name, bool, const char* doc);
  229. /**
  230. * Remove a variable definition from the build. This is not valid
  231. * for cache entries, and will only affect the current makefile.
  232. */
  233. void RemoveDefinition(const char* name);
  234. /**
  235. * Specify the name of the project for this build.
  236. */
  237. void SetProjectName(const char*);
  238. /**
  239. * Get the name of the project for this build.
  240. */
  241. const char* GetProjectName()
  242. {
  243. return this->ProjectName.c_str();
  244. }
  245. /**
  246. * Set the name of the library.
  247. */
  248. void AddLibrary(const char *libname, int shared,
  249. const std::vector<std::string> &srcs,
  250. bool excludeFromAll = false);
  251. #if defined(CMAKE_BUILD_WITH_CMAKE)
  252. /**
  253. * Add a source group for consideration when adding a new source.
  254. */
  255. void AddSourceGroup(const char* name, const char* regex=0,
  256. const char* parent=0);
  257. #endif
  258. /**
  259. * Add an auxiliary directory to the build.
  260. */
  261. void AddExtraDirectory(const char* dir);
  262. /**
  263. * Add an auxiliary directory to the build.
  264. */
  265. void MakeStartDirectoriesCurrent()
  266. {
  267. this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
  268. this->cmStartDirectory.c_str());
  269. this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
  270. this->StartOutputDirectory.c_str());
  271. }
  272. //@{
  273. /**
  274. * Set/Get the home directory (or output directory) in the project. The
  275. * home directory is the top directory of the project. It is where
  276. * CMakeSetup or configure was run. Remember that CMake processes
  277. * CMakeLists files by recursing up the tree starting at the StartDirectory
  278. * and going up until it reaches the HomeDirectory.
  279. */
  280. void SetHomeDirectory(const char* dir);
  281. const char* GetHomeDirectory() const
  282. {
  283. return this->cmHomeDirectory.c_str();
  284. }
  285. void SetHomeOutputDirectory(const char* lib);
  286. const char* GetHomeOutputDirectory() const
  287. {
  288. return this->HomeOutputDirectory.c_str();
  289. }
  290. //@}
  291. //@{
  292. /**
  293. * Set/Get the start directory (or output directory). The start directory
  294. * is the directory of the CMakeLists.txt file that started the current
  295. * round of processing. Remember that CMake processes CMakeLists files by
  296. * recursing up the tree starting at the StartDirectory and going up until
  297. * it reaches the HomeDirectory.
  298. */
  299. void SetStartDirectory(const char* dir)
  300. {
  301. this->cmStartDirectory = dir;
  302. cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
  303. this->cmStartDirectory =
  304. cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str());
  305. this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
  306. this->cmStartDirectory.c_str());
  307. }
  308. const char* GetStartDirectory() const
  309. {
  310. return this->cmStartDirectory.c_str();
  311. }
  312. void SetStartOutputDirectory(const char* lib)
  313. {
  314. this->StartOutputDirectory = lib;
  315. cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
  316. this->StartOutputDirectory =
  317. cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str());
  318. cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str());
  319. this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
  320. this->StartOutputDirectory.c_str());
  321. }
  322. const char* GetStartOutputDirectory() const
  323. {
  324. return this->StartOutputDirectory.c_str();
  325. }
  326. //@}
  327. const char* GetCurrentDirectory() const
  328. {
  329. return this->cmStartDirectory.c_str();
  330. }
  331. const char* GetCurrentOutputDirectory() const
  332. {
  333. return this->StartOutputDirectory.c_str();
  334. }
  335. /* Get the current CMakeLists.txt file that is being processed. This
  336. * is just used in order to be able to 'branch' from one file to a second
  337. * transparently */
  338. const char* GetCurrentListFile() const
  339. {
  340. return this->cmCurrentListFile.c_str();
  341. }
  342. //@}
  343. /**
  344. * Set a regular expression that include files must match
  345. * in order to be considered as part of the depend information.
  346. */
  347. void SetIncludeRegularExpression(const char* regex)
  348. {
  349. this->IncludeFileRegularExpression = regex;
  350. }
  351. const char* GetIncludeRegularExpression()
  352. {
  353. return this->IncludeFileRegularExpression.c_str();
  354. }
  355. /**
  356. * Set a regular expression that include files that are not found
  357. * must match in order to be considered a problem.
  358. */
  359. void SetComplainRegularExpression(const char* regex)
  360. {
  361. this->ComplainFileRegularExpression = regex;
  362. }
  363. const char* GetComplainRegularExpression()
  364. {
  365. return this->ComplainFileRegularExpression.c_str();
  366. }
  367. /**
  368. * Get the list of targets
  369. */
  370. cmTargets &GetTargets() { return this->Targets; }
  371. const cmTargets &GetImportedTargets() const { return this->ImportedTargets; }
  372. cmTarget* FindTarget(const char* name, bool useImportedTargets);
  373. /**
  374. * Get a list of include directories in the build.
  375. */
  376. std::vector<std::string>& GetIncludeDirectories()
  377. {
  378. return this->IncludeDirectories;
  379. }
  380. const std::vector<std::string>& GetIncludeDirectories() const
  381. {
  382. return this->IncludeDirectories;
  383. }
  384. void SetIncludeDirectories(const std::vector<std::string>& vec)
  385. {
  386. this->IncludeDirectories = vec;
  387. }
  388. /**
  389. * Mark include directories as system directories.
  390. */
  391. void AddSystemIncludeDirectory(const char* dir);
  392. bool IsSystemIncludeDirectory(const char* dir);
  393. /** Expand out any arguements in the vector that have ; separated
  394. * strings into multiple arguements. A new vector is created
  395. * containing the expanded versions of all arguments in argsIn.
  396. * This method differes from the one in cmSystemTools in that if
  397. * the CmakeLists file is version 1.2 or earlier it will check for
  398. * source lists being used without ${} around them
  399. */
  400. void ExpandSourceListArguments(std::vector<std::string> const& argsIn,
  401. std::vector<std::string>& argsOut,
  402. unsigned int startArgumentIndex);
  403. /** Get a cmSourceFile pointer for a given source name, if the name is
  404. * not found, then a null pointer is returned.
  405. */
  406. cmSourceFile* GetSource(const char* sourceName) const;
  407. ///! Add a new cmSourceFile to the list of sources for this makefile.
  408. cmSourceFile* AddSource(cmSourceFile const&);
  409. /** Get a cmSourceFile pointer for a given source name, if the name is
  410. * not found, then create the source file and return it. generated
  411. * indicates if it is a generated file, this is used in determining
  412. * how to create the source file instance e.g. name
  413. */
  414. cmSourceFile* GetOrCreateSource(const char* sourceName,
  415. bool generated = false);
  416. /**
  417. * Obtain a list of auxiliary source directories.
  418. */
  419. std::vector<std::string>& GetAuxSourceDirectories()
  420. {return this->AuxSourceDirectories;}
  421. //@{
  422. /**
  423. * Return a list of extensions associated with source and header
  424. * files
  425. */
  426. const std::vector<std::string>& GetSourceExtensions() const
  427. {return this->SourceFileExtensions;}
  428. const std::vector<std::string>& GetHeaderExtensions() const
  429. {return this->HeaderFileExtensions;}
  430. //@}
  431. /**
  432. * Given a variable name, return its value (as a string).
  433. * If the variable is not found in this makefile instance, the
  434. * cache is then queried.
  435. */
  436. const char* GetDefinition(const char*) const;
  437. const char* GetSafeDefinition(const char*) const;
  438. const char* GetRequiredDefinition(const char* name) const;
  439. bool IsDefinitionSet(const char*) const;
  440. /**
  441. * Get the list of all variables in the current space. If argument
  442. * cacheonly is specified and is greater than 0, then only cache
  443. * variables will be listed.
  444. */
  445. std::vector<std::string> GetDefinitions(int cacheonly=0) const;
  446. /** Test a boolean cache entry to see if it is true or false,
  447. * returns false if no entry defined.
  448. */
  449. bool IsOn(const char* name) const;
  450. bool IsSet(const char* name) const;
  451. /**
  452. * Get a list of preprocessor define flags.
  453. */
  454. const char* GetDefineFlags()
  455. {return this->DefineFlags.c_str();}
  456. /**
  457. * Make sure CMake can write this file
  458. */
  459. bool CanIWriteThisFile(const char* fileName);
  460. /**
  461. * Get the vector of used command instances.
  462. */
  463. const std::vector<cmCommand*>& GetUsedCommands() const
  464. {return this->UsedCommands;}
  465. #if defined(CMAKE_BUILD_WITH_CMAKE)
  466. /**
  467. * Get the vector source groups.
  468. */
  469. const std::vector<cmSourceGroup>& GetSourceGroups() const
  470. { return this->SourceGroups; }
  471. /**
  472. * Get the source group
  473. */
  474. cmSourceGroup* GetSourceGroup(const char* name);
  475. #endif
  476. /**
  477. * Get the vector of list files on which this makefile depends
  478. */
  479. const std::vector<std::string>& GetListFiles() const
  480. { return this->ListFiles; }
  481. ///! When the file changes cmake will be re-run from the build system.
  482. void AddCMakeDependFile(const char* file)
  483. { this->ListFiles.push_back(file);}
  484. /**
  485. * Get the list file stack as a string
  486. */
  487. std::string GetListFileStack();
  488. /**
  489. * Get the vector of files created by this makefile
  490. */
  491. const std::vector<std::string>& GetOutputFiles() const
  492. { return this->OutputFiles; }
  493. void AddCMakeOutputFile(const char* file)
  494. { this->OutputFiles.push_back(file);}
  495. /**
  496. * Expand all defined variables in the string.
  497. * Defined variables come from the this->Definitions map.
  498. * They are expanded with ${var} where var is the
  499. * entry in the this->Definitions map. Also @var@ is
  500. * expanded to match autoconf style expansions.
  501. */
  502. const char *ExpandVariablesInString(std::string& source);
  503. const char *ExpandVariablesInString(std::string& source, bool escapeQuotes,
  504. bool noEscapes,
  505. bool atOnly = false,
  506. const char* filename = 0,
  507. long line = -1,
  508. bool removeEmpty = false,
  509. bool replaceAt = true);
  510. /**
  511. * Remove any remaining variables in the string. Anything with ${var} or
  512. * @var@ will be removed.
  513. */
  514. void RemoveVariablesInString(std::string& source,
  515. bool atOnly = false) const;
  516. /**
  517. * Expand variables in the makefiles ivars such as link directories etc
  518. */
  519. void ExpandVariables();
  520. /**
  521. * Replace variables and #cmakedefine lines in the given string.
  522. * See cmConfigureFileCommand for details.
  523. */
  524. void ConfigureString(const std::string& input, std::string& output,
  525. bool atOnly, bool escapeQuotes);
  526. /**
  527. * Copy file but change lines acording to ConfigureString
  528. */
  529. int ConfigureFile(const char* infile, const char* outfile,
  530. bool copyonly, bool atOnly, bool escapeQuotes);
  531. #if defined(CMAKE_BUILD_WITH_CMAKE)
  532. /**
  533. * find what source group this source is in
  534. */
  535. cmSourceGroup& FindSourceGroup(const char* source,
  536. std::vector<cmSourceGroup> &groups);
  537. #endif
  538. void RegisterData(cmData*);
  539. void RegisterData(const char*, cmData*);
  540. cmData* LookupData(const char*) const;
  541. /**
  542. * Execute a single CMake command. Returns true if the command
  543. * succeeded or false if it failed.
  544. */
  545. bool ExecuteCommand(const cmListFileFunction& lff);
  546. /** Check if a command exists. */
  547. bool CommandExists(const char* name) const;
  548. /**
  549. * Add a command to this cmake instance
  550. */
  551. void AddCommand(cmCommand* );
  552. ///! Enable support for named language, if nil then all languages are
  553. ///enabled.
  554. void EnableLanguage(std::vector<std::string>const& languages);
  555. /**
  556. * Set/Get the name of the parent directories CMakeLists file
  557. * given a current CMakeLists file name
  558. */
  559. cmCacheManager *GetCacheManager() const;
  560. /**
  561. * Get the variable watch. This is used to determine when certain variables
  562. * are accessed.
  563. */
  564. #ifdef CMAKE_BUILD_WITH_CMAKE
  565. cmVariableWatch* GetVariableWatch() const;
  566. #endif
  567. ///! Display progress or status message.
  568. void DisplayStatus(const char*, float);
  569. /**
  570. * Expand the given list file arguments into the full set after
  571. * variable replacement and list expansion.
  572. */
  573. void ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
  574. std::vector<std::string>& outArgs);
  575. /**
  576. * Get the instance
  577. */
  578. cmake *GetCMakeInstance() const;
  579. /**
  580. * Get all the source files this makefile knows about
  581. */
  582. const std::vector<cmSourceFile*> &GetSourceFiles() const
  583. {return this->SourceFiles;}
  584. std::vector<cmSourceFile*> &GetSourceFiles() {return this->SourceFiles;}
  585. /**
  586. * Is there a source file that has the provided source file as an output?
  587. * if so then return it
  588. */
  589. cmSourceFile *GetSourceFileWithOutput(const char *outName);
  590. /**
  591. * Add a macro to the list of macros. The arguments should be name of the
  592. * macro and a documentation signature of it
  593. */
  594. void AddMacro(const char* name, const char* signature);
  595. ///! Add a new cmTest to the list of tests for this makefile.
  596. cmTest* CreateTest(const char* testName);
  597. /** Get a cmTest pointer for a given test name, if the name is
  598. * not found, then a null pointer is returned.
  599. */
  600. cmTest* GetTest(const char* testName) const;
  601. const std::vector<cmTest*> *GetTests() const;
  602. std::vector<cmTest*> *GetTests();
  603. /**
  604. * Get a list of macros as a ; separated string
  605. */
  606. void GetListOfMacros(std::string& macros);
  607. /**
  608. * Return a location of a file in cmake or custom modules directory
  609. */
  610. std::string GetModulesFile(const char* name);
  611. ///! Set/Get a property of this directory
  612. void SetProperty(const char *prop, const char *value);
  613. const char *GetProperty(const char *prop);
  614. const char *GetPropertyOrDefinition(const char *prop);
  615. const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
  616. bool GetPropertyAsBool(const char *prop);
  617. // Get the properties
  618. cmPropertyMap &GetProperties() { return this->Properties; };
  619. typedef std::map<cmStdString, cmStdString> DefinitionMap;
  620. ///! Initialize a makefile from its parent
  621. void InitializeFromParent();
  622. ///! Set/Get the preorder flag
  623. void SetPreOrder(bool p) { this->PreOrder = p; }
  624. bool GetPreOrder() { return this->PreOrder; }
  625. void AddInstallGenerator(cmInstallGenerator* g)
  626. { this->InstallGenerators.push_back(g); }
  627. std::vector<cmInstallGenerator*>& GetInstallGenerators()
  628. { return this->InstallGenerators; }
  629. // Define the properties
  630. static void DefineProperties(cmake *cm);
  631. protected:
  632. // add link libraries and directories to the target
  633. void AddGlobalLinkInformation(const char* name, cmTarget& target);
  634. std::string Prefix;
  635. std::vector<std::string> AuxSourceDirectories; //
  636. std::string cmStartDirectory;
  637. std::string StartOutputDirectory;
  638. std::string cmHomeDirectory;
  639. std::string HomeOutputDirectory;
  640. std::string cmCurrentListFile;
  641. std::string ProjectName; // project name
  642. // libraries, classes, and executables
  643. cmTargets Targets;
  644. cmTargets ImportedTargets;
  645. std::vector<cmSourceFile*> SourceFiles;
  646. // Tests
  647. std::vector<cmTest*> Tests;
  648. // The include and link-library paths. These may have order
  649. // dependency, so they must be vectors (not set).
  650. std::vector<std::string> IncludeDirectories;
  651. std::vector<std::string> LinkDirectories;
  652. // The set of include directories that are marked as system include
  653. // directories.
  654. std::set<cmStdString> SystemIncludeDirectories;
  655. std::vector<std::string> ListFiles; // list of command files loaded
  656. std::vector<std::string> OutputFiles; // list of command files loaded
  657. cmTarget::LinkLibraryVectorType LinkLibraries;
  658. std::vector<cmInstallGenerator*> InstallGenerators;
  659. std::string IncludeFileRegularExpression;
  660. std::string ComplainFileRegularExpression;
  661. std::vector<std::string> SourceFileExtensions;
  662. std::vector<std::string> HeaderFileExtensions;
  663. std::string DefineFlags;
  664. #if defined(CMAKE_BUILD_WITH_CMAKE)
  665. std::vector<cmSourceGroup> SourceGroups;
  666. #endif
  667. DefinitionMap Definitions;
  668. std::vector<cmCommand*> UsedCommands;
  669. cmLocalGenerator* LocalGenerator;
  670. bool IsFunctionBlocked(const cmListFileFunction& lff);
  671. private:
  672. void ReadSources(std::ifstream& fin, bool t);
  673. friend class cmMakeDepend; // make depend needs direct access
  674. // to the Sources array
  675. void PrintStringVector(const char* s, const
  676. std::vector<std::pair<cmStdString, bool> >& v) const;
  677. void PrintStringVector(const char* s,
  678. const std::vector<std::string>& v) const;
  679. void AddDefaultDefinitions();
  680. std::list<cmFunctionBlocker *> FunctionBlockers;
  681. typedef std::map<cmStdString, cmData*> DataMapType;
  682. DataMapType DataMap;
  683. typedef std::map<cmStdString, cmStdString> StringStringMap;
  684. StringStringMap MacrosMap;
  685. std::map<cmStdString, bool> SubDirectoryOrder;
  686. // used in AddDefinition for performance improvement
  687. DefinitionMap::key_type TemporaryDefinitionKey;
  688. cmsys::RegularExpression cmDefineRegex;
  689. cmsys::RegularExpression cmDefine01Regex;
  690. cmsys::RegularExpression cmAtVarRegex;
  691. cmPropertyMap Properties;
  692. // should this makefile be processed before or after processing the parent
  693. bool PreOrder;
  694. // stack of list files being read
  695. std::deque<cmStdString> ListFileStack;
  696. };
  697. #endif