@@ -138,13 +138,24 @@ def extract(self, overwrite=True):
138
138
os .chmod (path , 0o755 )
139
139
140
140
# Patch CMakeLists so that libgeos_c.so does not depend on libgeos.so.
141
- cmakefile = os .path .join (zipfold , "capi" , "CMakeLists.txt" )
141
+ if self .version_tuple < (3 , 8 , 0 ):
142
+ cmakefile = os .path .join (zipfold , "capi" , "CMakeLists.txt" )
143
+ oldtext = "target_link_libraries(geos_c geos)"
144
+ newtext = "target_link_libraries(geos_c geos-static)"
145
+ else :
146
+ cmakefile = os .path .join (zipfold , "CMakeLists.txt" )
147
+ oldtext = 'add_library(geos "")'
148
+ newtext = 'add_library(geos STATIC "")'
142
149
with io .open (cmakefile , "r" , encoding = "utf-8" ) as fd :
143
150
lines = fd .readlines ()
144
151
with io .open (cmakefile , "wb" ) as fd :
145
- oldtext = "target_link_libraries(geos_c geos)"
146
- newtext = "target_link_libraries(geos_c geos-static)"
152
+ found_sharedline = False
153
+ shared_oldtext = "if(BUILD_SHARED_LIBS)"
154
+ shared_newtext = "if(FALSE)"
147
155
for line in lines :
156
+ if not found_sharedline and shared_oldtext in line :
157
+ line = line .replace (shared_oldtext , shared_newtext )
158
+ found_sharedline = True
148
159
fd .write (line .replace (oldtext , newtext ).encode ())
149
160
150
161
# Apply specific patches for GEOS < 3.6.0.
@@ -184,9 +195,12 @@ def build(self, installdir=None, njobs=1):
184
195
# Define configure options.
185
196
config_opts = [
186
197
"-DCMAKE_INSTALL_PREFIX={0}" .format (installdir ),
187
- "-DGEOS_ENABLE_TESTS=OFF" ,
188
198
"-DCMAKE_BUILD_TYPE=Release" ,
189
199
]
200
+ if self .version_tuple < (3 , 8 , 0 ):
201
+ config_opts += ["-DGEOS_ENABLE_TESTS=OFF" ]
202
+ else :
203
+ config_opts += ["-DBUILD_TESTING=OFF" ]
190
204
if os .name == "nt" and self .version_tuple < (3 , 6 , 0 ):
191
205
config_opts = ["-G" , "NMake Makefiles" ] + config_opts
192
206
0 commit comments