summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2003-08-06 22:54:13 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2003-08-06 22:54:13 (GMT)
commit96d561aabc7ca453396b8d419b3398dea6b13572 (patch)
treecfb721d465938dc9d7f5454854897414c8006bd7
parent7d6aaf23e9c3d1ffe81c85791191658b797271f2 (diff)
downloadCMake-96d561aabc7ca453396b8d419b3398dea6b13572.zip
CMake-96d561aabc7ca453396b8d419b3398dea6b13572.tar.gz
CMake-96d561aabc7ca453396b8d419b3398dea6b13572.tar.bz2
ENH: Add option to retrieve list of macros. Close Bug #25 - Get_CMAKE_PROPERTIES
-rw-r--r--Source/cmGetCMakePropertyCommand.cxx4
-rw-r--r--Source/cmGetCMakePropertyCommand.h2
-rw-r--r--Source/cmMacroCommand.cxx9
-rw-r--r--Source/cmMakefile.cxx25
-rw-r--r--Source/cmMakefile.h14
-rw-r--r--Tests/SystemInformation/CMakeLists.txt13
-rw-r--r--Tests/SystemInformation/DumpInformation.cxx1
7 files changed, 67 insertions, 1 deletions
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index 0b66b14..43063af 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -63,6 +63,10 @@ bool cmGetCMakePropertyCommand::InitialPass(
cc++;
}
}
+ else if ( args[1] == "MACROS" )
+ {
+ m_Makefile->GetListOfMacros(output);
+ }
else
{
std::string emsg = "Unknown CMake property: " + args[1];
diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h
index 5a2eaf3..c040c23 100644
--- a/Source/cmGetCMakePropertyCommand.h
+++ b/Source/cmGetCMakePropertyCommand.h
@@ -57,7 +57,7 @@ public:
"Get a property from the CMake. The value of the property is"
"stored in the variable VAR. If the property is not found,"
"CMake will report an error. The properties include: VARIABLES, "
- "CACHE_VARIABLES, COMMANDS.";
+ "CACHE_VARIABLES, COMMANDS, and MACROS.";
}
cmTypeMacro(cmGetCMakePropertyCommand, cmCommand);
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 62d6724..391434e 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -30,6 +30,15 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
if(!expandedArguments.empty() && (expandedArguments[0] == m_Args[0]))
{
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;
}
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f61f7bf..70ca89d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2003,6 +2003,31 @@ cmVariableWatch *cmMakefile::GetVariableWatch() const
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
{
return this->GetCMakeInstance()->GetCacheManager();
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 19e712a..017ae70 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -603,6 +603,17 @@ public:
* if so then return it
*/
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:
// add link libraries and directories to the target
@@ -670,6 +681,9 @@ private:
DataMap m_DataMap;
bool m_Inheriting;
+ typedef std::map<cmStdString, cmStdString> StringStringMap;
+ StringStringMap m_MacrosMap;
+
// used in AddDefinition for performance improvement
DefinitionMap::key_type m_TemporaryDefinitionKey;
};
diff --git a/Tests/SystemInformation/CMakeLists.txt b/Tests/SystemInformation/CMakeLists.txt
index 93d93c6..c41f42b 100644
--- a/Tests/SystemInformation/CMakeLists.txt
+++ b/Tests/SystemInformation/CMakeLists.txt
@@ -6,6 +6,12 @@ CONFIGURE_FILE(${DumpInformation_SOURCE_DIR}/DumpInformation.h.in
${DumpInformation_BINARY_DIR}/DumpInformation.h)
ADD_EXECUTABLE(DumpInformation DumpInformation.cxx)
+MACRO(FOO args)
+ MESSAGE("Test macro")
+ENDMACRO(FOO)
+
+FOO(lala)
+
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt "")
GET_CMAKE_PROPERTY(res VARIABLES)
FOREACH(var ${res})
@@ -20,3 +26,10 @@ FOREACH(var ${res})
"${var}\n")
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})
+
diff --git a/Tests/SystemInformation/DumpInformation.cxx b/Tests/SystemInformation/DumpInformation.cxx
index 1c24721..9cf454a 100644
--- a/Tests/SystemInformation/DumpInformation.cxx
+++ b/Tests/SystemInformation/DumpInformation.cxx
@@ -54,6 +54,7 @@ int main(int,char *[])
DumpInformation_BINARY_DIR "/SystemInformation.out",
DumpInformation_BINARY_DIR "/AllVariables.txt",
DumpInformation_BINARY_DIR "/AllCommands.txt",
+ DumpInformation_BINARY_DIR "/AllMacros.txt",
DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
DumpInformation_BINARY_DIR "/../../CMakeOutput.log",