]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMLibrary.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / modelCDMLibrary.cpp
index 524f14257b6ac6e804a6dc0442005c35fd8bc21b..b124c930309cb0300b647c979933774aae50644e 100644 (file)
@@ -436,8 +436,76 @@ void modelCDMLibrary::CheckStructure(std::map<std::string, bool>& properties)
 
 std::map<std::string, bool> modelCDMLibrary::Get3rdPartyLibraries()
 {
+  std::map<std::string, std::string> correspondence;
+  correspondence["${crea_LIBRARIES}"] = "Crea";
+  correspondence["${WXWIDGETS_LIBRARIES}"] = "WxWidgets";
+  correspondence["${KWWidgets_LIBRARIES}"] = "KWWidgets";
+  correspondence["${VTK_LIBRARIES}"] = "VTK";
+  correspondence["${ITK_LIBRARIES}"] = "ITK";
+  correspondence["${GDCM_LIBRARIES}"] = "GDCM";
+  correspondence["${BOOST_LIBRARIES}"] = "Boost";
   std::map<std::string, bool> res;
-  res["Test"] = false;
+  res["Crea"] = false;
+  res["WxWidgets"] = false;
+  res["KWWidgets"] = false;
+  res["VTK"] = false;
+  res["ITK"] = false;
+  res["GDCM"] = false;
+  res["Boost"] = false;
+
+  if(this->HasCMakeLists())
+    {
+      std::ifstream CMFile(this->CMakeLists->GetPath().c_str());
+      if (CMFile.is_open())
+        {
+          std::string line;
+          while(!CMFile.eof())
+            {
+              std::getline(CMFile, line, '(');
+
+              std::vector<std::string> lineSeg;
+              CDMUtilities::splitter::split(lineSeg,line,"\n ",CDMUtilities::splitter::no_empties);
+
+              if(lineSeg.size() > 0 && lineSeg[lineSeg.size()-1] == "SET")
+                {
+                  //std::cout << "found set" << std::endl;
+                  std::getline(CMFile, line, ')');
+                  //std::cout << line << std::endl;
+                  CDMUtilities::splitter::split(lineSeg,line,"\n",CDMUtilities::splitter::no_empties);
+                  if(lineSeg.size() > 0)
+                    {
+                      //std::cout << lineSeg[0] << std::endl;
+                      for(int i = 0; i < lineSeg[0].size(); ++i)
+                        if (lineSeg[0][i] == ' ')
+                          {
+                            lineSeg[0].erase(i,1);
+                            --i;
+                          }
+                      //std::cout << lineSeg[0] << std::endl;
+                      if (lineSeg[0] == "${LIBRARY_NAME}_LINK_LIBRARIES")
+                        {
+                          //std::cout << "link" << std::endl;
+                          for (int l = 1; l < lineSeg.size(); ++l)
+                            {
+                              for(int i = 0;i < lineSeg[l].size(); i++)
+                                if (lineSeg[l][i] == ' ')
+                                  {
+                                    lineSeg[l].erase(i,1);
+                                    i--;
+                                  }
+                              if(lineSeg[l].size() > 0 && lineSeg[l][0] == '$')
+                                {
+                                  //std::cout << "found " << lineSeg[l] << std::endl;
+                                  res[correspondence[lineSeg[l]]] = true;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+          CMFile.close();
+        }
+    }
   return res;
 }