2000-08-29 23:26:29 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: Insight Segmentation & Registration Toolkit
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2000 National Library of Medicine
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
See COPYRIGHT.txt for copyright details.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
/**
|
2000-09-12 13:30:35 +04:00
|
|
|
* cmMakefile - used to parse and store the contents of a
|
|
|
|
* CMakeLists.txt makefile in memory.
|
2000-08-29 23:26:29 +04:00
|
|
|
*/
|
|
|
|
#ifndef cmMakefile_h
|
|
|
|
#define cmMakefile_h
|
2001-01-05 19:41:20 +03:00
|
|
|
#include "cmStandardIncludes.h"
|
2000-08-29 23:26:29 +04:00
|
|
|
#include "cmClassFile.h"
|
2001-01-05 19:41:20 +03:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
class cmRuleMaker;
|
|
|
|
class cmMakefileGenerator;
|
|
|
|
|
2000-08-29 23:26:29 +04:00
|
|
|
|
|
|
|
class cmMakefile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmMakefile();
|
2001-01-05 19:41:20 +03:00
|
|
|
~cmMakefile();
|
|
|
|
// Parse a CMakeLists.txt file
|
|
|
|
bool ReadMakefile(const char* makefile, bool inheriting = false);
|
|
|
|
// Add a wrap generator
|
|
|
|
void AddRuleMaker(cmRuleMaker* );
|
|
|
|
// Set the make file
|
|
|
|
void SetMakefileGenerator(cmMakefileGenerator*);
|
|
|
|
// Generate the output file
|
|
|
|
void GenerateMakefile();
|
|
|
|
|
2000-08-29 23:26:29 +04:00
|
|
|
// Print useful stuff to stdout
|
|
|
|
void Print();
|
2001-01-05 19:41:20 +03:00
|
|
|
|
|
|
|
// cmRuleMaker interfaces
|
|
|
|
void AddCustomRule(const char* source,
|
|
|
|
const char* result,
|
|
|
|
const char* command,
|
|
|
|
std::vector<std::string>& depends);
|
|
|
|
void AddDefineFlag(const char* definition);
|
|
|
|
void AddExecutable(cmClassFile&);
|
|
|
|
void AddLinkLibrary(const char*);
|
|
|
|
void AddLinkDirectory(const char*);
|
|
|
|
void AddSubDirectory(const char*);
|
|
|
|
void AddIncludeDirectory(const char*);
|
|
|
|
void AddDefinition(const char* name, const char* value);
|
|
|
|
void SetProjectName(const char*);
|
|
|
|
void SetLibraryName(const char*);
|
|
|
|
void AddClass(cmClassFile& );
|
|
|
|
void AddExtraDirectory(const char* dir);
|
|
|
|
|
2000-08-29 23:26:29 +04:00
|
|
|
// Set the home directory for the project
|
|
|
|
void SetHomeDirectory(const char* dir)
|
|
|
|
{
|
|
|
|
m_cmHomeDirectory = dir;
|
2001-01-05 19:41:20 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
|
2000-08-29 23:26:29 +04:00
|
|
|
}
|
|
|
|
const char* GetHomeDirectory()
|
|
|
|
{
|
|
|
|
return m_cmHomeDirectory.c_str();
|
|
|
|
}
|
|
|
|
// Set the current directory in the project
|
|
|
|
void SetCurrentDirectory(const char* dir)
|
|
|
|
{
|
|
|
|
m_cmCurrentDirectory = dir;
|
|
|
|
}
|
|
|
|
const char* GetCurrentDirectory()
|
|
|
|
{
|
|
|
|
return m_cmCurrentDirectory.c_str();
|
|
|
|
}
|
|
|
|
// Set the name of the library that is built by this makefile
|
|
|
|
const char* GetLibraryName()
|
|
|
|
{
|
|
|
|
return m_LibraryName.c_str();
|
|
|
|
}
|
2001-01-05 19:41:20 +03:00
|
|
|
|
2000-09-27 23:01:19 +04:00
|
|
|
const char* GetProjectName()
|
|
|
|
{
|
|
|
|
return m_ProjectName.c_str();
|
|
|
|
}
|
2000-08-29 23:26:29 +04:00
|
|
|
|
|
|
|
// Set the name of the library that is built by this makefile
|
|
|
|
void SetOutputDirectory(const char* lib)
|
|
|
|
{
|
|
|
|
m_OutputDirectory = lib;
|
|
|
|
}
|
|
|
|
const char* GetOutputDirectory()
|
|
|
|
{
|
|
|
|
return m_OutputDirectory.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the name of the library that is built by this makefile
|
|
|
|
void SetOutputHomeDirectory(const char* lib)
|
|
|
|
{
|
|
|
|
m_OutputHomeDirectory = lib;
|
|
|
|
}
|
|
|
|
const char* GetOutputHomeDirectory()
|
|
|
|
{
|
|
|
|
return m_OutputHomeDirectory.c_str();
|
|
|
|
}
|
2000-09-12 13:30:35 +04:00
|
|
|
const std::vector<std::string>& GetSubDirectories()
|
|
|
|
{
|
|
|
|
return m_SubDirectories;
|
|
|
|
}
|
2000-08-29 23:26:29 +04:00
|
|
|
|
2000-09-27 23:01:19 +04:00
|
|
|
bool HasExecutables()
|
|
|
|
{
|
|
|
|
return m_Executables;
|
|
|
|
}
|
|
|
|
|
2001-01-05 19:41:20 +03:00
|
|
|
std::vector<std::string>& GetIncludeDirectories()
|
|
|
|
{
|
|
|
|
return m_IncludeDirectories;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string>& GetLinkDirectories()
|
|
|
|
{
|
|
|
|
return m_LinkDirectories;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string>& GetLinkLibraries()
|
|
|
|
{
|
|
|
|
return m_LinkLibraries;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string>& GetLinkLibrariesWin32()
|
|
|
|
{
|
|
|
|
return m_LinkLibrariesWin32;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string>& GetLinkLibrariesUnix()
|
|
|
|
{
|
|
|
|
return m_LinkLibrariesUnix;
|
|
|
|
}
|
|
|
|
std::vector<cmClassFile>& GetClasses(){ return m_Classes;}
|
|
|
|
std::vector<std::string>& GetAuxSourceDirectories()
|
|
|
|
{ return m_AuxSourceDirectories; }
|
|
|
|
std::vector<std::string>& GetMakeVerbatim()
|
|
|
|
{ return m_MakeVerbatim;}
|
|
|
|
const char* GetDefinition(const char*);
|
|
|
|
|
|
|
|
const char* GetDefineFlags()
|
|
|
|
{ return m_DefineFlags.c_str();}
|
|
|
|
|
2000-08-29 23:26:29 +04:00
|
|
|
private:
|
2001-01-05 19:41:20 +03:00
|
|
|
/**
|
|
|
|
* Look for CMakeLists.txt files to parse in dir,
|
|
|
|
* then in dir's parents, until the SourceHome directory
|
|
|
|
* is found.
|
|
|
|
*/
|
|
|
|
void ParseDirectory(const char* dir);
|
|
|
|
/**
|
|
|
|
* Parse a file for includes links and libs
|
|
|
|
*/
|
|
|
|
void ExpandVaribles();
|
2000-08-29 23:26:29 +04:00
|
|
|
void ReadClasses(std::ifstream& fin, bool t);
|
|
|
|
friend class cmMakeDepend; // make depend needs direct access
|
2001-01-05 19:41:20 +03:00
|
|
|
// to the m_Classes array
|
|
|
|
void PrintStringVector(const char* s, std::vector<std::string>& v);
|
|
|
|
void AddDefaultRules();
|
2000-08-29 23:26:29 +04:00
|
|
|
protected:
|
|
|
|
bool m_Executables;
|
|
|
|
std::string m_Prefix;
|
2001-01-05 19:41:20 +03:00
|
|
|
std::vector<std::string> m_AuxSourceDirectories; //
|
2000-08-29 23:26:29 +04:00
|
|
|
std::string m_OutputDirectory; // Current output directory for makefile
|
|
|
|
std::string m_OutputHomeDirectory; // Top level output directory
|
|
|
|
std::string m_cmHomeDirectory; // Home directory for source
|
|
|
|
std::string m_cmCurrentDirectory; // current directory in source
|
|
|
|
std::string m_LibraryName; // library name
|
2000-09-27 23:01:19 +04:00
|
|
|
std::string m_ProjectName; // project name
|
2000-08-29 23:26:29 +04:00
|
|
|
std::vector<cmClassFile> m_Classes; // list of classes in makefile
|
|
|
|
std::vector<std::string> m_SubDirectories; // list of sub directories
|
2000-09-12 13:30:35 +04:00
|
|
|
std::vector<std::string> m_MakeVerbatim; // lines copied from input file
|
2001-01-05 19:41:20 +03:00
|
|
|
std::vector<std::string> m_IncludeDirectories;
|
|
|
|
std::vector<std::string> m_LinkDirectories;
|
|
|
|
std::vector<std::string> m_LinkLibraries;
|
|
|
|
std::vector<std::string> m_LinkLibrariesWin32;
|
|
|
|
std::vector<std::string> m_LinkLibrariesUnix;
|
|
|
|
std::string m_DefineFlags;
|
|
|
|
std::string m_SourceHomeDirectory;
|
|
|
|
struct customRule
|
|
|
|
{
|
|
|
|
std::string m_Source;
|
|
|
|
std::string m_Result;
|
|
|
|
std::string m_Command;
|
|
|
|
std::vector<std::string> m_Depends;
|
|
|
|
};
|
|
|
|
std::vector<customRule> m_CustomRules;
|
|
|
|
typedef std::map<std::string, cmRuleMaker*> StringRuleMakerMap;
|
|
|
|
typedef std::map<std::string, std::string> DefinitionMap;
|
|
|
|
DefinitionMap m_Definitions;
|
|
|
|
StringRuleMakerMap m_RuleMakers;
|
|
|
|
std::vector<cmRuleMaker*> m_UsedRuleMakers;
|
|
|
|
cmMakefileGenerator* m_MakefileGenerator;
|
2000-08-29 23:26:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|