소스 검색

ENH: Added option to IF command to test if a command exists. Syntax is IF(COMMAND name-of-command).

Brad King 24 년 전
부모
커밋
fd37e46eb3
3개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 0
      Source/cmIfCommand.cxx
  2. 4 2
      Source/cmMakefile.cxx
  3. 2 0
      Source/cmMakefile.h

+ 8 - 0
Source/cmIfCommand.cxx

@@ -110,6 +110,14 @@ bool cmIfCommand::InitialPass(std::vector<std::string> const& args)
       }
     }
 
+  if (args.size() == 2 && (args[0] == "COMMAND"))
+    {
+    if(!m_Makefile->CommandExists(args[1].c_str()))
+      {
+      f = new cmIfFunctionBlocker();
+      }
+    }
+
   if (args.size() == 3 && (args[1] == "AND"))
     {
     def = m_Makefile->GetDefinition(args[0].c_str());

+ 4 - 2
Source/cmMakefile.cxx

@@ -214,7 +214,10 @@ void cmMakefile::Print() const
     }
 }
 
-
+bool cmMakefile::CommandExists(const char* name) const
+{
+  return (m_Commands.find(name) != m_Commands.end());
+}
       
 void cmMakefile::ExecuteCommand(std::string &name,
                                 std::vector<std::string> const& arguments)
@@ -1187,7 +1190,6 @@ cmMakefile::FindSourceGroup(const char* source,
   return groups.front();
 }
 
-
 bool cmMakefile::IsFunctionBlocked(const char *name,
                                    std::vector<std::string> const&args)
 {

+ 2 - 0
Source/cmMakefile.h

@@ -534,6 +534,8 @@ public:
    */
   void ExecuteCommand(std::string &name, std::vector<std::string> const& args);
   
+  /** Check if a command exists. */
+  bool CommandExists(const char* name) const;
     
 protected:
   std::string m_Prefix;