@@ -154,12 +154,13 @@ bool baseProject::create(const fs::path & _path, string templateName){
154154 // if (!fs::exists(projectDir)) {
155155 // fs::create_directory(projectDir);
156156 // }
157- bool bDoesDirExist = false ;
157+ bool bDoesSrcDirExist = false ;
158158
159- fs::path project { projectDir / " src" };
159+ // it can be only "src"
160+ fs::path projectSrc { projectDir / " src" };
160161
161- if (fs::exists (project ) && fs::is_directory (project )) {
162- bDoesDirExist = true ;
162+ if (fs::exists (projectSrc ) && fs::is_directory (projectSrc )) {
163+ bDoesSrcDirExist = true ;
163164 } else {
164165 for (auto & p : { fs::path (" src" ), fs::path (" bin" ) }) {
165166 try {
@@ -214,40 +215,37 @@ bool baseProject::create(const fs::path & _path, string templateName){
214215
215216 parseConfigMake ();
216217
217- if (bDoesDirExist){
218- vector < fs::path > fileNames;
219- getFilesRecursively (projectDir / " src" , fileNames);
218+ if (bDoesSrcDirExist){
219+ vector <fs::path> fileNames;
220+
221+ // CWD is already on projectDir. so with this we get relative paths
222+ getFilesRecursively (" src" , fileNames);
220223
221224 std::sort (fileNames.begin (), fileNames.end (), [](const fs::path & a, const fs::path & b) {
222225 return a.string () < b.string ();
223226 });
224- for (auto & f : fileNames) {
225- fs::path rel { fs::relative (f, projectDir) };
226- fs::path folder { rel.parent_path () };
227-
228- string fileName = rel.string ();
229-
230- if (fileName != " src/ofApp.cpp" &&
231- fileName != " src/ofApp.h" &&
232- fileName != " src/main.cpp" &&
233- fileName != " src/ofApp.mm" &&
234- fileName != " src/main.mm" ) {
235- addSrc (rel.string (), folder.string ());
227+ for (const auto & f : fileNames) {
228+ if (f != " src/ofApp.cpp" &&
229+ f != " src/ofApp.h" &&
230+ f != " src/main.cpp" &&
231+ f != " src/ofApp.mm" &&
232+ f != " src/main.mm" ) {
233+ addSrc (f, f.parent_path ());
236234 } else {
237235 }
238236 }
239- // FIXME: Port to std::list, so no comparison is needed.
240- vector < fs::path > paths ;
237+
238+ std::set< fs::path> uniquePaths ;
241239 for (auto & f : fileNames) {
242- fs::path rel { fs::relative ( fs::path (f) .parent_path (), projectDir) } ;
243- if ( std::find (paths. begin (), paths. end (), rel) == paths. end ()) {
244- paths. emplace_back (rel);
245- if ( containsSourceFiles (rel) ) {
246- ofLogVerbose () << " [prjFiles-addIncludeDir] contains src - Adding dir: [ " << rel. string () << " ] " ;
247- addInclude (rel) ;
248- } else {
249- ofLogVerbose () << " [prjFiles-addIncludeDir] no src - not adding: [ " << rel. string () << " ] " ;
250- }
240+ uniquePaths. insert (f .parent_path ()) ;
241+ }
242+
243+ for ( auto & p : uniquePaths ) {
244+ if ( containsSourceFiles (p)) {
245+ ofLogVerbose () << " [prjFiles-addIncludeDir] contains src - Adding dir: " << p ;
246+ addInclude (p);
247+ } else {
248+ ofLogVerbose () << " [prjFiles-addIncludeDir] no src - not adding: " << p;
251249 }
252250 }
253251 }
0 commit comments