+
+ std::vector<std::string> vers;
+ CDMUtilities::splitter::split(vers, version, " .", CDMUtilities::splitter::no_empties);
+
+ time_t now = time(0);
+ tm* ltm = localtime(&now);
+
+ std::stringstream date;
+ date << ltm->tm_mday << "/" << 1 + ltm->tm_mon << "/" << 1900 + ltm->tm_year;
+
+ //set name of library in CMakeLists inside copied folder
+ std::string line;
+ std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
+ if( !in.is_open())
+ {
+ result = new std::string("CMakeLists.txt file failed to open.");
+ return false;
+ }
+ std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
+ if( !out.is_open())
+ {
+ result = new std::string("CMakeLists.txt.tmp file failed to open.");
+ return false;
+ }
+ while (getline(in, line))
+ {
+ if(line.find("SET(PROJECT_MAJOR_VERSION") != std::string::npos)
+ line = "SET(PROJECT_MAJOR_VERSION " + vers[0] + ")";
+ else if(line.find("SET(PROJECT_MINOR_VERSION") != std::string::npos)
+ line = "SET(PROJECT_MINOR_VERSION " + vers[1] + ")";
+ else if(line.find("SET(PROJECT_BUILD_VERSION") != std::string::npos)
+ line = "SET(PROJECT_BUILD_VERSION " + vers[2] + ")";
+ else if(line.find("SET(PROJECT_VERSION_DATE") != std::string::npos)
+ line = "SET(PROJECT_VERSION_DATE \"" + date.str() + "\")";
+ out << line << std::endl;
+ }
+ in.close();
+ out.close();
+ //delete old file and rename new file
+ std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
+ if(system(renameCommand.c_str()))
+ {
+ result = new std::string("An error occurred while running '" + renameCommand + "'.");
+ return false;
+ }
+
+ this->version = vers[0] + "." + vers[1] + "." + vers[2];
+ this->versionDate = date.str();