Browse Source

made project name from cmakelists.txt more flexible

merge-requests/365/head
tedjk 11 years ago
parent
commit
7eeb0470ac
  1. 17
      juci/directories.cc
  2. 1
      juci/directories.h

17
juci/directories.cc

@ -95,18 +95,29 @@ get_project_name(const boost::filesystem::path& dir_path) {
size_t variabel_end = line.find("}", variabel_start); size_t variabel_end = line.find("}", variabel_start);
project_name_var = line.substr(variabel_start+1, project_name_var = line.substr(variabel_start+1,
(variabel_end)-variabel_start-1); (variabel_end)-variabel_start-1);
boost::algorithm::trim(project_name_var);
if (variabel_start == std::string::npos) { // not a variabel
variabel_start = line.find("(", 0);
variabel_end = line.find(")", variabel_start);
return line.substr(variabel_start+1,
(variabel_end)-variabel_start-1);
}
break; break;
} }
} }
std::ifstream ifs2(itr->path().string()); std::ifstream ifs2(itr->path().string());
while (std::getline(ifs2, line)) { while (std::getline(ifs2, line)) {
if (line.find("set("+project_name_var, 0) != std::string::npos) { if (line.find("set(", 0) != std::string::npos
|| line.find("set (", 0) != std::string::npos) {
if( line.find(project_name_var, 0) != std::string::npos) {
size_t variabel_start = line.find(project_name_var, 0) size_t variabel_start = line.find(project_name_var, 0)
+project_name_var.length(); +project_name_var.length();
size_t variabel_end = line.find(")", variabel_start); size_t variabel_end = line.find(")", variabel_start);
project_name = line.substr(variabel_start, project_name = line.substr(variabel_start+1,
variabel_end-variabel_start); variabel_end-variabel_start-1);
boost::algorithm::trim(project_name);
return project_name; return project_name;
}
} }
} }
break; break;

1
juci/directories.h

@ -4,6 +4,7 @@
#include <gtkmm.h> #include <gtkmm.h>
#include <glib.h> #include <glib.h>
#include "boost/filesystem.hpp" #include "boost/filesystem.hpp"
#include "boost/algorithm/string.hpp"
#include <utility> #include <utility>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>

Loading…
Cancel
Save