@@ -75,45 +75,47 @@ def addSourceDir(self):
75
75
self .makeFile .write ("\n " )
76
76
77
77
def addIncludeDirs (self ):
78
- self .makeFile .write ("message(\" Adding include directories\" )\n " )
79
- # Add project/module include dirs
80
- incPath = self .parser .buildOptions ["incPath" ]
81
- self .makeFile .write ("include_directories(" + incPath .replace ("\\ " , "/" ) + ")\n " )
82
- # for incDir in os.listdir(incPath):
83
- # self.makeFile.write("include_directories(" + os.path.join(incPath, incDir).replace("\\", "/") + ")\n")
84
-
85
- # Add dependency includes - This may be local, that is, within the same project hierarchy (another
86
- # module) or external, that is, brought in by maven to this project's/module's target area.
87
- for dep in self .dependencies .values ():
88
- # mvnDep = dep.mvnDep
89
- if dep .foundLocal :
90
- headerPath = os .path .join (self .parser .localModules [dep .groupId + "." + dep .artifactId ], "src" ,
91
- "main" , "include" )
92
- else :
93
- headerPath = os .path .join (self .libPath , dep .artifactId + "-" + dep .version + self .headerPostfix ,
94
- "include" )
95
- if os .path .exists (headerPath ):
96
- self .makeFile .write ("include_directories(" + headerPath .replace ("\\ " , "/" ) + ")\n " )
97
- else :
98
- self .log .error ("header path " + headerPath + " does not exist. Currently not supporting test includes." )
78
+ if "incPath" in self .parser .buildOptions :
79
+ self .makeFile .write ("message(\" Adding include directories\" )\n " )
80
+ # Add project/module include dirs
81
+ incPath = self .parser .buildOptions ["incPath" ]
82
+ self .makeFile .write ("include_directories(" + incPath .replace ("\\ " , "/" ) + ")\n " )
83
+ # for incDir in os.listdir(incPath):
84
+ # self.makeFile.write("include_directories(" + os.path.join(incPath, incDir).replace("\\", "/") + ")\n")
85
+
86
+ # Add dependency includes - This may be local, that is, within the same project hierarchy (another
87
+ # module) or external, that is, brought in by maven to this project's/module's target area.
88
+ for dep in self .dependencies .values ():
89
+ # mvnDep = dep.mvnDep
90
+ if dep .foundLocal :
91
+ headerPath = os .path .join (self .parser .localModules [dep .groupId + "." + dep .artifactId ], "src" ,
92
+ "main" , "include" )
93
+ else :
94
+ headerPath = os .path .join (self .libPath , dep .artifactId + "-" + dep .version + self .headerPostfix ,
95
+ "include" )
96
+ if os .path .exists (headerPath ):
97
+ self .makeFile .write ("include_directories(" + headerPath .replace ("\\ " , "/" ) + ")\n " )
98
+ else :
99
+ self .log .error ("header path " + headerPath + " does not exist. Currently not supporting test includes." )
99
100
self .makeFile .write ("\n " )
100
101
101
102
def addAllSources (self ):
102
- self .makeFile .write ("message(\" Setting sources\" )\n " )
103
- srcPath = self .parser .buildOptions ["srcPath" ]
104
- sources = []
105
- for srcDir in os .listdir (os .path .join (self .projectPath , srcPath )):
106
- subSrcPath = os .path .join (self .projectPath , srcPath , srcDir )
107
- if not os .path .isfile (subSrcPath ):
108
- for file in os .listdir (subSrcPath ):
103
+ if "srcPath" in self .parser .buildOptions :
104
+ self .makeFile .write ("message(\" Setting sources\" )\n " )
105
+ srcPath = self .parser .buildOptions ["srcPath" ]
106
+ sources = []
107
+ for srcDir in os .listdir (os .path .join (self .projectPath , srcPath )):
108
+ subSrcPath = os .path .join (self .projectPath , srcPath , srcDir )
109
+ if not os .path .isfile (subSrcPath ):
110
+ for file in os .listdir (subSrcPath ):
111
+ if file .endswith (tuple (self .srcExts )):
112
+ sources .append (os .path .join (srcPath , srcDir , file ))
113
+ else :
114
+ file = subSrcPath
109
115
if file .endswith (tuple (self .srcExts )):
110
116
sources .append (os .path .join (srcPath , srcDir , file ))
111
- else :
112
- file = subSrcPath
113
- if file .endswith (tuple (self .srcExts )):
114
- sources .append (os .path .join (srcPath , srcDir , file ))
115
117
116
- self .makeFile .write ("set(SOURCES \n \t " + "\n \t " .join (sources ).replace ("\\ " , "/" ) + ")\n " )
118
+ self .makeFile .write ("set(SOURCES \n \t " + "\n \t " .join (sources ).replace ("\\ " , "/" ) + ")\n " )
117
119
self .makeFile .write ("\n " )
118
120
119
121
def linkDirectories (self ):
@@ -126,35 +128,37 @@ def setOutputDir(self):
126
128
127
129
# Currently no checks are carried otu for header only libs so there may be superfluous find_library entries
128
130
def addLinkLibraries (self ):
129
- self .makeFile .write ("message(\" Finding libraries\" )\n " )
130
- for dep in self .dependencies .values ():
131
- if dep .scope is not "compile" :
132
- self .log .warn ("Only supporting compile scope. " + dep .getFullNarName () + " is " + dep .scope )
133
- continue
134
-
135
- if not dep .foundLocal :
136
- # Find in target/nar
137
- libPath = os .path .join (self .libPath , dep .getFullNarName ("gpp" ), "lib" , dep .getAol ("gpp" ), dep .libType )
138
- if not os .path .exists (libPath ):
139
- self .log .warn (
140
- "Could not find external library " + dep .getFullNarName () + ". You need to use maven to pull down the dependencies or this is a header only lib." )
131
+ if len (self .dependencies ) > 0 :
132
+ self .makeFile .write ("message(\" Finding libraries\" )\n " )
133
+ for dep in self .dependencies .values ():
134
+ if dep .scope is not "compile" :
135
+ self .log .warn ("Only supporting compile scope. " + dep .getFullNarName () + " is " + dep .scope )
141
136
continue
142
- else :
143
- # This is an internal module so we need to build it if it doesn't exist...how?
144
- libPath = os .path .join (dep .path , self .cmakeTarget )
145
-
146
- libId = dep .artifactId .upper ()
147
- self .makeFile .write (
148
- "find_library(" + libId + " " + dep .artifactId + " HINTS " + libPath .replace ("\\ " , "/" ) + ")\n " )
149
- self .libsTolink .append (libId )
137
+
138
+ if not dep .foundLocal :
139
+ # Find in target/nar
140
+ libPath = os .path .join (self .libPath , dep .getFullNarName ("gpp" ), "lib" , dep .getAol ("gpp" ), dep .libType )
141
+ if not os .path .exists (libPath ):
142
+ self .log .warn (
143
+ "Could not find external library " + dep .getFullNarName () + ". You need to use maven to pull down the dependencies or this is a header only lib." )
144
+ continue
145
+ else :
146
+ # This is an internal module so we need to build it if it doesn't exist...how?
147
+ libPath = os .path .join (dep .path , self .cmakeTarget )
148
+
149
+ libId = dep .artifactId .upper ()
150
+ self .makeFile .write (
151
+ "find_library(" + libId + " " + dep .artifactId + " HINTS " + libPath .replace ("\\ " , "/" ) + ")\n " )
152
+ self .libsTolink .append (libId )
150
153
self .makeFile .write ("\n " )
151
154
152
155
153
156
def linkLibraries (self ):
154
- self .makeFile .write ("message(\" Creating library linkage\" )\n " )
155
- for libToLink in self .libsTolink :
156
- self .makeFile .write ("target_link_libraries(" + self .binaryName + " ${" + libToLink + "})" )
157
- self .makeFile .write ("\n " )
157
+ if len (self .libsTolink ) > 0 :
158
+ self .makeFile .write ("message(\" Creating library linkage\" )\n " )
159
+ for libToLink in self .libsTolink :
160
+ self .makeFile .write ("target_link_libraries(" + self .binaryName + " ${" + libToLink + "})" )
161
+ self .makeFile .write ("\n " )
158
162
159
163
160
164
0 commit comments