summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmAbstractFilesCommand.h2
-rw-r--r--Source/cmAddTargetCommand.h2
-rw-r--r--Source/cmAuxSourceDirectoryCommand.h2
-rw-r--r--Source/cmCommand.h37
-rw-r--r--Source/cmExecutablesCommand.h2
-rw-r--r--Source/cmFindIncludeCommand.h2
-rw-r--r--Source/cmFindLibraryCommand.h2
-rw-r--r--Source/cmFindProgramCommand.h2
-rw-r--r--Source/cmIncludeDirectoryCommand.h2
-rw-r--r--Source/cmLibraryCommand.h2
-rw-r--r--Source/cmLinkDirectoriesCommand.h2
-rw-r--r--Source/cmLinkLibrariesCommand.h2
-rw-r--r--Source/cmProjectCommand.h2
-rw-r--r--Source/cmSourceFilesCommand.h2
-rw-r--r--Source/cmSourceFilesRequireCommand.h2
-rw-r--r--Source/cmSubdirCommand.h2
-rw-r--r--Source/cmTestsCommand.h2
-rw-r--r--Source/cmUnixDefinesCommand.h2
-rw-r--r--Source/cmUnixLibrariesCommand.h2
-rw-r--r--Source/cmWin32DefinesCommand.h2
-rw-r--r--Source/cmWin32LibrariesCommand.h2
21 files changed, 77 insertions, 0 deletions
diff --git a/Source/cmAbstractFilesCommand.h b/Source/cmAbstractFilesCommand.h
index 6e7f73e..a40cce8 100644
--- a/Source/cmAbstractFilesCommand.h
+++ b/Source/cmAbstractFilesCommand.h
@@ -54,6 +54,8 @@ public:
return
"ABSTRACT_FILES(file1 file2 ..)";
}
+
+ cmTypeMacro(cmAbstractFilesCommand, cmCommand);
};
diff --git a/Source/cmAddTargetCommand.h b/Source/cmAddTargetCommand.h
index 01653e6..fd0aeab 100644
--- a/Source/cmAddTargetCommand.h
+++ b/Source/cmAddTargetCommand.h
@@ -65,6 +65,8 @@ public:
return
"ADD_TARGET(Name \"command to run\")";
}
+
+ cmTypeMacro(cmAddTargetCommand, cmCommand);
};
#endif
diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h
index c830a76..905d63a 100644
--- a/Source/cmAuxSourceDirectoryCommand.h
+++ b/Source/cmAuxSourceDirectoryCommand.h
@@ -67,6 +67,8 @@ public:
return
"AUX_SOURCE_DIRECTORY(dir)";
}
+
+ cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand);
};
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index aefd757..55841c4 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -122,6 +122,19 @@ public:
const char* GetError()
{return m_Error.c_str();}
+ /**
+ * Returns true if this class is the given class, or a subclass of it.
+ */
+ static bool IsTypeOf(const char *type)
+ { return !strcmp("cmCommand", type); }
+
+ /**
+ * Returns true if this object is an instance of the given class or
+ * a subclass of it.
+ */
+ virtual bool IsA(const char *type)
+ { return cmCommand::IsTypeOf(type); }
+
protected:
void SetError(const char* e)
{
@@ -136,4 +149,28 @@ private:
std::string m_Error;
};
+// All subclasses of cmCommand should invoke this macro.
+#define cmTypeMacro(thisClass,superclass) \
+static bool IsTypeOf(const char *type) \
+{ \
+ if ( !strcmp(#thisClass,type) ) \
+ { \
+ return true; \
+ } \
+ return superclass::IsTypeOf(type); \
+} \
+virtual bool IsA(const char *type) \
+{ \
+ return thisClass::IsTypeOf(type); \
+} \
+static thisClass* SafeDownCast(cmCommand *c) \
+{ \
+ if ( c && c->IsA(#thisClass) ) \
+ { \
+ return (thisClass *)c; \
+ } \
+ return 0;\
+}
+
+
#endif
diff --git a/Source/cmExecutablesCommand.h b/Source/cmExecutablesCommand.h
index c420a87..48b013f 100644
--- a/Source/cmExecutablesCommand.h
+++ b/Source/cmExecutablesCommand.h
@@ -63,6 +63,8 @@ public:
return
"EXECUTABLES(file1 file2 ...)";
}
+
+ cmTypeMacro(cmExecutablesCommand, cmCommand);
};
diff --git a/Source/cmFindIncludeCommand.h b/Source/cmFindIncludeCommand.h
index 4b2cd4a..7381032 100644
--- a/Source/cmFindIncludeCommand.h
+++ b/Source/cmFindIncludeCommand.h
@@ -70,6 +70,8 @@ public:
return
"FIND_INCLUDE(DEFINE try1 try2 ...)";
}
+
+ cmTypeMacro(cmFindIncludeCommand, cmCommand);
};
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
index eca2e60..f1e26a2 100644
--- a/Source/cmFindLibraryCommand.h
+++ b/Source/cmFindLibraryCommand.h
@@ -71,6 +71,8 @@ public:
return
"FIND_LIBRARY(DEFINE libraryName path1 path2 path3...)";
}
+
+ cmTypeMacro(cmFindLibraryCommand, cmCommand);
};
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index 8aa7ee9..4b6d58c 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -71,6 +71,8 @@ public:
return
"FIND_PROGRAM(NAME executable1 executable2 ...)";
}
+
+ cmTypeMacro(cmFindProgramCommand, cmCommand);
};
diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h
index 4236880..8011e53 100644
--- a/Source/cmIncludeDirectoryCommand.h
+++ b/Source/cmIncludeDirectoryCommand.h
@@ -69,6 +69,8 @@ public:
return
"INCLUDE_DIRECTORIES(dir1 dir2 ...)";
}
+
+ cmTypeMacro(cmIncludeDirectoryCommand, cmCommand);
};
diff --git a/Source/cmLibraryCommand.h b/Source/cmLibraryCommand.h
index 74957cb..0abb2dd 100644
--- a/Source/cmLibraryCommand.h
+++ b/Source/cmLibraryCommand.h
@@ -64,6 +64,8 @@ public:
return
"LIBRARY(libraryname)";
}
+
+ cmTypeMacro(cmLibraryCommand, cmCommand);
};
diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h
index 783c880..36a6ad8 100644
--- a/Source/cmLinkDirectoriesCommand.h
+++ b/Source/cmLinkDirectoriesCommand.h
@@ -74,6 +74,8 @@ public:
"The directories can use built in definitions like \n"
"CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR.";
}
+
+ cmTypeMacro(cmLinkDirectoriesCommand, cmCommand);
};
diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h
index 31e9310..5f01d52 100644
--- a/Source/cmLinkLibrariesCommand.h
+++ b/Source/cmLinkLibrariesCommand.h
@@ -76,6 +76,8 @@ public:
"down to all other commands. The library name should be\n"
"the same as the name used in the LIBRARY(library) command.";
}
+
+ cmTypeMacro(cmLinkLibrariesCommand, cmCommand);
};
diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h
index fe395b0..7c0c673 100644
--- a/Source/cmProjectCommand.h
+++ b/Source/cmProjectCommand.h
@@ -74,6 +74,8 @@ public:
return
"PROJECT(projectname) Sets the name of the Microsoft workspace .dsw file. Does nothing on UNIX currently\n";
}
+
+ cmTypeMacro(cmProjectCommand, cmCommand);
};
diff --git a/Source/cmSourceFilesCommand.h b/Source/cmSourceFilesCommand.h
index f534339..6ff44b2 100644
--- a/Source/cmSourceFilesCommand.h
+++ b/Source/cmSourceFilesCommand.h
@@ -68,6 +68,8 @@ public:
return
"SOURCE_FILES(file1 file2 ...)";
}
+
+ cmTypeMacro(cmSourceFilesCommand, cmCommand);
};
diff --git a/Source/cmSourceFilesRequireCommand.h b/Source/cmSourceFilesRequireCommand.h
index e84c21e..b7253b7 100644
--- a/Source/cmSourceFilesRequireCommand.h
+++ b/Source/cmSourceFilesRequireCommand.h
@@ -67,6 +67,8 @@ public:
return
"SOURCE_FILES_REQUIRE(var1 var2 ... SOURCES_BEGIN file1 file2 ...)";
}
+
+ cmTypeMacro(cmSourceFilesRequireCommand, cmCommand);
};
diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h
index 43a501e..fd8b346 100644
--- a/Source/cmSubdirCommand.h
+++ b/Source/cmSubdirCommand.h
@@ -67,6 +67,8 @@ public:
"This will cause any CMakeLists.txt files in the sub directories\n"
"to be processed by CMake.";
}
+
+ cmTypeMacro(cmSubdirCommand, cmCommand);
};
diff --git a/Source/cmTestsCommand.h b/Source/cmTestsCommand.h
index ec001b3..0a9fd93 100644
--- a/Source/cmTestsCommand.h
+++ b/Source/cmTestsCommand.h
@@ -67,6 +67,8 @@ public:
return
"TESTS(file1 file2 ...)";
}
+
+ cmTypeMacro(cmTestsCommand, cmCommand);
};
diff --git a/Source/cmUnixDefinesCommand.h b/Source/cmUnixDefinesCommand.h
index f912ff4..595792c 100644
--- a/Source/cmUnixDefinesCommand.h
+++ b/Source/cmUnixDefinesCommand.h
@@ -75,6 +75,8 @@ public:
"UNIX_DEFINES(-DFOO -DBAR)\n"
"Add -D flags to the command line for Unix only.";
}
+
+ cmTypeMacro(cmUnixDefinesCommand, cmCommand);
};
diff --git a/Source/cmUnixLibrariesCommand.h b/Source/cmUnixLibrariesCommand.h
index 80a77a4..e3c883d 100644
--- a/Source/cmUnixLibrariesCommand.h
+++ b/Source/cmUnixLibrariesCommand.h
@@ -74,6 +74,8 @@ public:
return
"UNIX_LIBRARIES(library -lm ...)";
}
+
+ cmTypeMacro(cmUnixLibrariesCommand, cmCommand);
};
diff --git a/Source/cmWin32DefinesCommand.h b/Source/cmWin32DefinesCommand.h
index a8e0da8..af07265 100644
--- a/Source/cmWin32DefinesCommand.h
+++ b/Source/cmWin32DefinesCommand.h
@@ -75,6 +75,8 @@ public:
"WIN32_DEFINES(-DFOO -DBAR ...)\n"
"Add -D define flags to command line for Win32 environments.";
}
+
+ cmTypeMacro(cmWin32DefinesCommand, cmCommand);
};
diff --git a/Source/cmWin32LibrariesCommand.h b/Source/cmWin32LibrariesCommand.h
index 61d7b18..02885af 100644
--- a/Source/cmWin32LibrariesCommand.h
+++ b/Source/cmWin32LibrariesCommand.h
@@ -74,6 +74,8 @@ public:
return
"WIN32_LIBRARIES(library -lm ...)";
}
+
+ cmTypeMacro(cmWin32LibrariesCommand, cmCommand);
};