@@ -8,46 +8,72 @@ bool visualStudioProject::createProjectFile(){
88// alert("visualStudioProject::createProjectFile");
99
1010 ensureDllDirectoriesExist ();
11+ solution = projectDir / (projectName + " .sln" );
1112
12- solution = projectDir / (projectName + " .sln" );
13- fs::path project { projectDir / (projectName + " .vcxproj" ) };
14- fs::path user { projectDir / (projectName + " .vcxproj.user" ) };
15- fs::path filters { projectDir / (projectName + " .vcxproj.filters" ) };
13+ std::pair <string, string> replacements;
14+ if (!fs::equivalent (getOFRoot (), fs::path{ " ../../.." })) {
15+ string root { getOFRoot ().string () };
16+ string relRootWindows { convertStringToWindowsSeparator (root) + " \\ " };
17+
18+ replacements = { " ..\\ ..\\ ..\\ " , relRootWindows };
19+ } else {
20+ // cout << "equivalent to default ../../.." << endl;
21+ }
22+
23+ // solution
24+ copyTemplateFiles.push_back ({
25+ templatePath / " emptyExample.sln" ,
26+ projectDir / (projectName + " .sln" ),
27+ {
28+ { " emptyExample" , projectName },
29+ replacements
30+ }
31+ });
32+
33+ // project
34+ copyTemplateFiles.push_back ({
35+ templatePath / " emptyExample.vcxproj" ,
36+ projectDir / (projectName + " .vcxproj" ),
37+ {
38+ { " emptyExample" , projectName },
39+ replacements
40+ }
1641
17- fs::copy (templatePath / " emptyExample.vcxproj" , project, fs::copy_options::overwrite_existing);
18- fs::copy (templatePath / " emptyExample.vcxproj.user" , user, fs::copy_options::overwrite_existing);
19- fs::copy (templatePath / " emptyExample.sln" , solution, fs::copy_options::overwrite_existing);
20- fs::copy (templatePath / " emptyExample.vcxproj.filters" , filters, fs::copy_options::overwrite_existing);
42+ });
43+
44+ // user
45+ copyTemplateFiles.push_back ({
46+ templatePath / " emptyExample.vcxproj.user" ,
47+ projectDir / (projectName + " .vcxproj.user" ),
48+ {{ " emptyExample" , projectName }}
49+
50+ });
51+
52+ // filters
53+ copyTemplateFiles.push_back ({
54+ templatePath / " emptyExample.vcxproj.filters" ,
55+ projectDir / (projectName + " .vcxproj.filters" )
56+ });
57+
58+ // icon
59+ copyTemplateFiles.push_back ({
60+ templatePath / " icon.rc" ,
61+ projectDir / " icon.rc"
62+ });
63+
64+ for (auto & c : copyTemplateFiles) {
65+ c.run ();
66+ }
2167
22- fs::copy (templatePath / " icon.rc" , projectDir / " icon.rc" , fs::copy_options::overwrite_existing);
68+
69+ fs::path filters { projectDir / (projectName + " .vcxproj.filters" ) };
2370
2471 pugi::xml_parse_result result = filterXmlDoc.load_file (filters.c_str ());
2572 if (result.status ==pugi::status_ok) {
2673 ofLogVerbose () << " loaded filter " ;
2774 } else {
2875 ofLogVerbose () << " problem loading filter " ;
2976 }
30-
31- findandreplaceInTexfile (solution, " emptyExample" , projectName);
32- findandreplaceInTexfile (user, " emptyExample" , projectName);
33- findandreplaceInTexfile (project, " emptyExample" , projectName);
34-
35-
36- if (!fs::equivalent (getOFRoot (), fs::path{ " ../../.." })) {
37- string root { getOFRoot ().string () };
38- string relRootWindows { convertStringToWindowsSeparator (root) + " \\ " };
39-
40- // sln has windows paths:
41- // alert ("replacing root with " + relRootWindows, 36);
42- findandreplaceInTexfile (solution, " ..\\ ..\\ ..\\ " , relRootWindows);
43-
44- // vcx has unixy paths:
45- // ..\..\..\libs
46- findandreplaceInTexfile (project, " ..\\ ..\\ ..\\ " , relRootWindows);
47- } else {
48- // cout << "equivalent to default ../../.." << endl;
49- }
50-
5177 return true ;
5278}
5379
@@ -205,7 +231,7 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold
205231 nodeAdded.append_child("Filter").append_child(pugi::node_pcdata).set_value(folder.c_str());*/
206232
207233 } else if (ext == " .storyboard" || ext == " .mm" ) {
208- // Do not add files for other platforms
234+ // Do not add files for other platforms
209235 } else {
210236 appendValue (doc, " ClCompile" , " Include" , srcFileString);
211237
0 commit comments