@@ -8,46 +8,72 @@ bool visualStudioProject::createProjectFile(){
8
8
// alert("visualStudioProject::createProjectFile");
9
9
10
10
ensureDllDirectoriesExist ();
11
+ solution = projectDir / (projectName + " .sln" );
11
12
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
+ }
16
41
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
+ }
21
67
22
- fs::copy (templatePath / " icon.rc" , projectDir / " icon.rc" , fs::copy_options::overwrite_existing);
68
+
69
+ fs::path filters { projectDir / (projectName + " .vcxproj.filters" ) };
23
70
24
71
pugi::xml_parse_result result = filterXmlDoc.load_file (filters.c_str ());
25
72
if (result.status ==pugi::status_ok) {
26
73
ofLogVerbose () << " loaded filter " ;
27
74
} else {
28
75
ofLogVerbose () << " problem loading filter " ;
29
76
}
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
-
51
77
return true ;
52
78
}
53
79
@@ -205,7 +231,7 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold
205
231
nodeAdded.append_child("Filter").append_child(pugi::node_pcdata).set_value(folder.c_str());*/
206
232
207
233
} else if (ext == " .storyboard" || ext == " .mm" ) {
208
- // Do not add files for other platforms
234
+ // Do not add files for other platforms
209
235
} else {
210
236
appendValue (doc, " ClCompile" , " Include" , srcFileString);
211
237
0 commit comments