]> Creatis software - crea.git/commitdiff
Feature #1711 CreaDevManager application implementation
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Wed, 24 Apr 2013 12:01:09 +0000 (14:01 +0200)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Wed, 24 Apr 2013 12:01:09 +0000 (14:01 +0200)
Fix: When a 3rd pary inclusion in package cmakelist is OFF the inclusion should change the instruction to ON instead of creating another because the create a conflict and the library inclusion becomes undetermined.

lib/creaDevManagerLib/modelCDMPackage.cpp
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/wxCDMProjectConfigurationDialog.cpp

index e565dec98f6728bdc933c7a75d01cf9f6ee6a736..5816dc43684d60f655c4705c6f2726f7b2b797c0 100644 (file)
@@ -763,20 +763,13 @@ bool modelCDMPackage::Set3rdPartyLibrary(const std::string& library_name,
   if (correspondence.find(library_name) != correspondence.end())
     {
       std::string library_command = correspondence[library_name];
-//      std::cout << "found correspondence " << library_command << std::endl;
-//      std::cout.flush();
       if (this->HasCMakeLists())
         {
           std::string CMfile = CDMUtilities::readFile(this->CMakeLists->GetPath().c_str());
           std::string resCMfile = "";
           bool found = false;
 
-//          std::cout << "found cmakefile: " << CMfile << std::endl;
-//          std::cout.flush();
-
           try {
-//            std::cout << "first regex" << std::endl;
-//            std::cout.flush();
             boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}"+library_command+"([\\s]|#[^\\n]*\\n)+ON([\\s]|#[^\\n]*\\n)*\\)");
 
             std::string::const_iterator start, end;
@@ -786,8 +779,6 @@ bool modelCDMPackage::Set3rdPartyLibrary(const std::string& library_name,
             boost::match_flag_type flags = boost::match_default;
             if(boost::regex_search(start, end, what, expression, flags))
               {
-//                std::cout << "found " << what.str() << std::endl;
-//                std::cout.flush();
                 found = true;
                 resCMfile += what.prefix().str();
                 if (toInclude)
@@ -800,49 +791,69 @@ bool modelCDMPackage::Set3rdPartyLibrary(const std::string& library_name,
               }
             else
               {
-//                std::cout << "second regex" << std::endl;
-//                std::cout.flush();
-                boost::regex expression("^\\h*#\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}"+library_command+"([\\s]|#[^\\n]*\\n)+ON([\\s]|#[^\\n]*\\n)*\\)");
+                boost::regex expression("^\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}"+library_command+"([\\s]|#[^\\n]*\\n)+OFF([\\s]|#[^\\n]*\\n)*\\)");
+
+                start = CMfile.begin();
+                end = CMfile.end();
                 if(boost::regex_search(start, end, what, expression, flags))
                   {
                     found = true;
                     resCMfile += what.prefix().str();
-                    if(toInclude)
+                    if (toInclude)
                       {
-                        std::string dete = what[0].str();
-                        for (int i = 0; i < dete.size(); ++i) {
-                          if (dete[i] != '#')
-                            resCMfile.push_back(dete[i]);
-                          if (dete[i] == 'S')
-                            {
-                              resCMfile += dete.substr(i+1);
-                              break;
-                            }
-                        }
+                        std::string dete = what.str();
+                        int pos = dete.rfind("OFF");
+                        dete.replace(pos, 3, "ON");
+                        resCMfile += dete;
                       }
                     else
                       resCMfile += what.str();
-
                     resCMfile += what.suffix().str();
+
                     return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
                   }
                 else
                   {
-//                    std::cout << "third regex" << std::endl;
-//                    std::cout.flush();
-                    boost::regex expression("^\\h*#\\h*UNCOMMENT EACH LIBRARY NEEDED \\(WILL BE FOUND AND USED AUTOMATICALLY\\)[^\\n]*\\n");
+                    boost::regex expression("^\\h*#\\h*SET([\\s]|#[^\\n]*\\n)*\\(([\\s]|#[^\\n]*\\n)*\\$\\{BBTK_PACKAGE_NAME\\}"+library_command+"([\\s]|#[^\\n]*\\n)+ON([\\s]|#[^\\n]*\\n)*\\)");
                     if(boost::regex_search(start, end, what, expression, flags))
                       {
                         found = true;
                         resCMfile += what.prefix().str();
-                        resCMfile += what.str();
                         if(toInclude)
                           {
-                            resCMfile += "SET(${BBTK_PACKAGE_NAME}"+ library_command +"  ON)\n";
+                            std::string dete = what[0].str();
+                            for (int i = 0; i < dete.size(); ++i) {
+                              if (dete[i] != '#')
+                                resCMfile.push_back(dete[i]);
+                              if (dete[i] == 'S')
+                                {
+                                  resCMfile += dete.substr(i+1);
+                                  break;
+                                }
+                            }
                           }
+                        else
+                          resCMfile += what.str();
+
                         resCMfile += what.suffix().str();
                         return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
                       }
+                    else
+                      {
+                        boost::regex expression("^\\h*#\\h*UNCOMMENT EACH LIBRARY NEEDED \\(WILL BE FOUND AND USED AUTOMATICALLY\\)[^\\n]*\\n");
+                        if(boost::regex_search(start, end, what, expression, flags))
+                          {
+                            found = true;
+                            resCMfile += what.prefix().str();
+                            resCMfile += what.str();
+                            if(toInclude)
+                              {
+                                resCMfile += "SET(${BBTK_PACKAGE_NAME}"+ library_command +"  ON)\n";
+                              }
+                            resCMfile += what.suffix().str();
+                            return CDMUtilities::writeFile(this->CMakeLists->GetPath().c_str(), resCMfile);
+                          }
+                      }
                   }
               }
           } catch (boost::bad_expression& e) {
index dff1b63728b2fe054d5514cd4d4e9d430b717a06..7edde9ad3738891b6aba77479c0084c5c7068be6 100644 (file)
@@ -1138,7 +1138,7 @@ std::map<std::string, bool> modelCDMProject::Get3rdPartyLibraries()
       boost::match_flag_type flags = boost::match_default;
       while(boost::regex_search(start, end, what, expression, flags))
         {
-          std::cout << what[0].str() << std::endl;
+          //std::cout << what[0].str() << std::endl;
           boost::regex expression1 = boost::regex("USE_\\w+");
           std::string::const_iterator start1, end1;
           start1 = what[0].first;
@@ -1148,7 +1148,7 @@ std::map<std::string, bool> modelCDMProject::Get3rdPartyLibraries()
             {
               std::string dete = what1.str();
               CDMUtilities::normalizeStr(dete);
-              std::cout << dete << std::endl;
+              //std::cout << dete << std::endl;
               if(correspondence.find(dete) != correspondence.end())
                 res[correspondence[dete]] = true;
             }
index d26fbb363236d7404bdfd0ebf5bd48ce68f5d415..add92a6fda5a8d38e5389d22b38a00a72ee6f5c7 100644 (file)
@@ -129,10 +129,10 @@ void wxCDMProjectConfigurationDialog::CreateControls()
       );
     ChBIncl->SetToolTip(crea::std2wx(
         "When this box is checked the " + it->first + " library\n"
-        "is included in the project configuration for\n"
-        "this package including the following instruction\n"
-        "in the package's folder CMakeLists.txt file:\n"
-        "SET(${BBTK_PACKAGE_NAME}_USE_" + it->first+ "  ON)\n"
+        "is included in the project configuration\n"
+        "including the following instruction\n"
+        "in the project's folder CMakeLists.txt file:\n"
+        "SET(USE_" + it->first+ "  ON)\n"
         ));
     ChBIncl->SetName(crea::std2wx(it->first));
     ChBIncl->SetValue(it->second);