ENH: Add option to retrieve list of macros. Close Bug #25 - Get_CMAKE_PROPERTIES

This commit is contained in:
Andy Cedilnik 2003-08-06 18:54:13 -04:00
parent 7d6aaf23e9
commit 96d561aabc
7 changed files with 67 additions and 1 deletions

View File

@ -63,6 +63,10 @@ bool cmGetCMakePropertyCommand::InitialPass(
cc++; cc++;
} }
} }
else if ( args[1] == "MACROS" )
{
m_Makefile->GetListOfMacros(output);
}
else else
{ {
std::string emsg = "Unknown CMake property: " + args[1]; std::string emsg = "Unknown CMake property: " + args[1];

View File

@ -57,7 +57,7 @@ public:
"Get a property from the CMake. The value of the property is" "Get a property from the CMake. The value of the property is"
"stored in the variable VAR. If the property is not found," "stored in the variable VAR. If the property is not found,"
"CMake will report an error. The properties include: VARIABLES, " "CMake will report an error. The properties include: VARIABLES, "
"CACHE_VARIABLES, COMMANDS."; "CACHE_VARIABLES, COMMANDS, and MACROS.";
} }
cmTypeMacro(cmGetCMakePropertyCommand, cmCommand); cmTypeMacro(cmGetCMakePropertyCommand, cmCommand);

View File

@ -30,6 +30,15 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0])) if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0]))
{ {
m_Executing = true; m_Executing = true;
std::string name = m_Args[0];
std::vector<std::string>::size_type cc;
name += "(";
for ( cc = 0; cc < m_Args.size(); cc ++ )
{
name += " " + m_Args[cc];
}
name += " )";
mf.AddMacro(m_Args[0].c_str(), name.c_str());
return true; return true;
} }
} }

View File

@ -2003,6 +2003,31 @@ cmVariableWatch *cmMakefile::GetVariableWatch() const
return 0; return 0;
} }
void cmMakefile::AddMacro(const char* name, const char* signature)
{
if ( !name || !signature )
{
return;
}
m_MacrosMap[name] = signature;
}
void cmMakefile::GetListOfMacros(std::string& macros)
{
StringStringMap::iterator it;
macros = "";
int cc;
for ( it = m_MacrosMap.begin(); it != m_MacrosMap.end(); ++it )
{
if ( cc > 0 )
{
macros += ";";
}
macros += it->first;
cc ++;
}
}
cmCacheManager *cmMakefile::GetCacheManager() const cmCacheManager *cmMakefile::GetCacheManager() const
{ {
return this->GetCMakeInstance()->GetCacheManager(); return this->GetCMakeInstance()->GetCacheManager();

View File

@ -603,6 +603,17 @@ public:
* if so then return it * if so then return it
*/ */
cmSourceFile *GetSourceFileWithOutput(const char *outName); cmSourceFile *GetSourceFileWithOutput(const char *outName);
/**
* Add a macro to the list of macros. The arguments should be name of the
* macro and a documentation signature of it
*/
void AddMacro(const char* name, const char* signature);
/**
* Get a list of macros as a ; separated string
*/
void GetListOfMacros(std::string& macros);
protected: protected:
// add link libraries and directories to the target // add link libraries and directories to the target
@ -670,6 +681,9 @@ private:
DataMap m_DataMap; DataMap m_DataMap;
bool m_Inheriting; bool m_Inheriting;
typedef std::map<cmStdString, cmStdString> StringStringMap;
StringStringMap m_MacrosMap;
// used in AddDefinition for performance improvement // used in AddDefinition for performance improvement
DefinitionMap::key_type m_TemporaryDefinitionKey; DefinitionMap::key_type m_TemporaryDefinitionKey;
}; };

View File

@ -6,6 +6,12 @@ CONFIGURE_FILE(${DumpInformation_SOURCE_DIR}/DumpInformation.h.in
${DumpInformation_BINARY_DIR}/DumpInformation.h) ${DumpInformation_BINARY_DIR}/DumpInformation.h)
ADD_EXECUTABLE(DumpInformation DumpInformation.cxx) ADD_EXECUTABLE(DumpInformation DumpInformation.cxx)
MACRO(FOO args)
MESSAGE("Test macro")
ENDMACRO(FOO)
FOO(lala)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt "") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt "")
GET_CMAKE_PROPERTY(res VARIABLES) GET_CMAKE_PROPERTY(res VARIABLES)
FOREACH(var ${res}) FOREACH(var ${res})
@ -20,3 +26,10 @@ FOREACH(var ${res})
"${var}\n") "${var}\n")
ENDFOREACH(var ${res}) ENDFOREACH(var ${res})
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/AllMacros.txt "")
GET_CMAKE_PROPERTY(res MACROS)
FOREACH(var ${res})
FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/AllMacros.txt
"${var}\n")
ENDFOREACH(var ${res})

View File

@ -54,6 +54,7 @@ int main(int,char *[])
DumpInformation_BINARY_DIR "/SystemInformation.out", DumpInformation_BINARY_DIR "/SystemInformation.out",
DumpInformation_BINARY_DIR "/AllVariables.txt", DumpInformation_BINARY_DIR "/AllVariables.txt",
DumpInformation_BINARY_DIR "/AllCommands.txt", DumpInformation_BINARY_DIR "/AllCommands.txt",
DumpInformation_BINARY_DIR "/AllMacros.txt",
DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h", DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
DumpInformation_BINARY_DIR "/../../CMakeCache.txt", DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
DumpInformation_BINARY_DIR "/../../CMakeOutput.log", DumpInformation_BINARY_DIR "/../../CMakeOutput.log",