8
8
import os
9
9
import textwrap
10
10
11
- required_conan_version = ">=1.53 .0"
11
+ required_conan_version = ">=1.52 .0"
12
12
13
13
14
14
class LeptonicaConan (ConanFile ):
@@ -55,9 +55,18 @@ def configure(self):
55
55
if self .options .with_tiff :
56
56
self .options ["libtiff" ].jpeg = self .options .with_jpeg
57
57
if self .options .shared :
58
- self .options .rm_safe ("fPIC" )
59
- self .settings .rm_safe ("compiler.cppstd" )
60
- self .settings .rm_safe ("compiler.libcxx" )
58
+ try :
59
+ del self .options .fPIC
60
+ except Exception :
61
+ pass
62
+ try :
63
+ del self .settings .compiler .libcxx
64
+ except Exception :
65
+ pass
66
+ try :
67
+ del self .settings .compiler .cppstd
68
+ except Exception :
69
+ pass
61
70
62
71
def layout (self ):
63
72
cmake_layout (self , src_folder = "src" )
@@ -72,7 +81,7 @@ def requirements(self):
72
81
if self .options .with_jpeg == "libjpeg-turbo" :
73
82
self .requires ("libjpeg-turbo/2.1.4" )
74
83
if self .options .with_png :
75
- self .requires ("libpng/1.6.39 " )
84
+ self .requires ("libpng/1.6.38 " )
76
85
if self .options .with_tiff :
77
86
self .requires ("libtiff/4.4.0" )
78
87
if self .options .with_openjpeg :
@@ -99,9 +108,6 @@ def generate(self):
99
108
tc .variables ["STATIC" ] = not self .options .shared
100
109
tc .variables ["BUILD_PROG" ] = False
101
110
tc .variables ["SW_BUILD" ] = False
102
- if Version (self .version ) >= "1.83.0" :
103
- tc .variables ["LIBWEBP_SUPPORT" ] = self .options .with_webp
104
- tc .variables ["OPENJPEG_SUPPORT" ] = self .options .with_openjpeg
105
111
tc .generate ()
106
112
deps = CMakeDeps (self )
107
113
deps .generate ()
@@ -133,69 +139,47 @@ def _patch_sources(self):
133
139
replace_in_file (self , cmakelists_src , "${GIF_LIBRARIES}" , "GIF::GIF" )
134
140
if not self .options .with_gif :
135
141
replace_in_file (self , cmakelists_src , "if (GIF_LIBRARIES)" , "if(0)" )
136
- if Version (self .version ) >= "1.83.0" :
137
- replace_in_file (self , cmake_configure , "if(GIF_FOUND)" , "if(0)" )
138
- else :
139
- replace_in_file (self , cmake_configure , "if (GIF_FOUND)" , "if(0)" )
142
+ replace_in_file (self , cmake_configure , "if (GIF_FOUND)" , "if(0)" )
140
143
## libjpeg
141
144
replace_in_file (self , cmakelists_src , "${JPEG_LIBRARIES}" , "JPEG::JPEG" )
142
145
if not self .options .with_jpeg :
143
146
replace_in_file (self , cmakelists_src , "if (JPEG_LIBRARIES)" , "if(0)" )
144
- if Version (self .version ) >= "1.83.0" :
145
- replace_in_file (self , cmake_configure , "if(JPEG_FOUND)" , "if(0)" )
146
- else :
147
- replace_in_file (self , cmake_configure , "if (JPEG_FOUND)" , "if(0)" )
147
+ replace_in_file (self , cmake_configure , "if (JPEG_FOUND)" , "if(0)" )
148
148
## libpng
149
149
replace_in_file (self , cmakelists_src , "${PNG_LIBRARIES}" , "PNG::PNG" )
150
150
if not self .options .with_png :
151
151
replace_in_file (self , cmakelists_src , "if (PNG_LIBRARIES)" , "if(0)" )
152
- if Version (self .version ) >= "1.83.0" :
153
- replace_in_file (self , cmake_configure , "if(PNG_FOUND)" , "if(0)" )
154
- else :
155
- replace_in_file (self , cmake_configure , "if (PNG_FOUND)" , "if(0)" )
152
+ replace_in_file (self , cmake_configure , "if (PNG_FOUND)" , "if(0)" )
156
153
## libtiff
157
154
replace_in_file (self , cmakelists_src , "${TIFF_LIBRARIES}" , "TIFF::TIFF" )
158
155
if not self .options .with_tiff :
159
156
replace_in_file (self , cmakelists_src , "if (TIFF_LIBRARIES)" , "if(0)" )
160
- if Version (self .version ) >= "1.83.0" :
161
- replace_in_file (self , cmake_configure , "if(TIFF_FOUND)" , "if(0)" )
162
- else :
163
- replace_in_file (self , cmake_configure , "if (TIFF_FOUND)" , "if(0)" )
157
+ replace_in_file (self , cmake_configure , "if (TIFF_FOUND)" , "if(0)" )
164
158
## We have to be more aggressive with dependencies found with pkgconfig
165
159
## Injection of libdirs is ensured by conan_basic_setup()
166
160
## openjpeg
167
- replace_in_file (self , cmakelists_src , "${JP2K_LIBRARIES}" , "openjp2" )
168
- if Version (self .version ) < "1.83.0" :
169
- # pkgconfig is prefered to CMake. Disable pkgconfig so only CMake is used
170
- if Version (self .version ) <= "1.78.0" :
171
- replace_in_file (self , cmakelists , "pkg_check_modules(JP2K libopenjp2)" , "" )
172
- else :
173
- replace_in_file (self , cmakelists , "pkg_check_modules(JP2K libopenjp2>=2.0 QUIET)" , "" )
174
- # versions below 1.83.0 do not have an option toggle
175
- replace_in_file (self , cmakelists , "if(NOT JP2K)" , "if(0)" )
176
- if not self .options .with_openjpeg :
177
- replace_in_file (self , cmakelists_src , "if (JP2K_FOUND)" , "if(0)" )
178
- replace_in_file (self , cmake_configure , "if (JP2K_FOUND)" , "if(0)" )
179
- else :
180
- replace_in_file (self , cmakelists , "set(JP2K_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIRS})" , "set(JP2K_INCLUDE_DIRS ${OpenJPEG_INCLUDE_DIRS})" )
181
- if not self .options .with_openjpeg :
182
- replace_in_file (self , cmake_configure , "if(JP2K_FOUND)" , "if(0)" )
183
-
161
+ replace_in_file (self , cmakelists , "if(NOT JP2K)" , "if(0)" )
162
+ replace_in_file (self , cmakelists_src ,
163
+ "if (JP2K_FOUND)" ,
164
+ "if (JP2K_FOUND)\n "
165
+ "target_link_directories(leptonica PRIVATE ${JP2K_LIBRARY_DIRS})\n "
166
+ "target_compile_definitions(leptonica PRIVATE ${JP2K_CFLAGS_OTHER})" )
167
+ if not self .options .with_openjpeg :
168
+ replace_in_file (self , cmakelists_src , "if (JP2K_FOUND)" , "if(0)" )
169
+ replace_in_file (self , cmake_configure , "if (JP2K_FOUND)" , "if(0)" )
184
170
## libwebp
185
- if Version (self .version ) < "1.83.0" :
186
- # versions below 1.83.0 do not have an option toggle
187
- replace_in_file (self , cmakelists , "if(NOT WEBP)" , "if(0)" )
188
- if Version (self .version ) >= "1.79.0" :
189
- replace_in_file (self , cmakelists , "if(NOT WEBPMUX)" , "if(0)" )
190
- if not self .options .with_webp :
191
- replace_in_file (self , cmakelists_src , "if (WEBP_FOUND)" , "if(0)" )
192
- replace_in_file (self , cmake_configure , "if (WEBP_FOUND)" , "if(0)" )
171
+ replace_in_file (self , cmakelists , "if(NOT WEBP)" , "if(0)" )
193
172
replace_in_file (self , cmakelists_src ,
194
173
"if (WEBP_FOUND)" ,
195
174
"if (WEBP_FOUND)\n "
196
175
"target_link_directories(leptonica PRIVATE ${WEBP_LIBRARY_DIRS} ${WEBPMUX_LIBRARY_DIRS})\n "
197
176
"target_compile_definitions(leptonica PRIVATE ${WEBP_CFLAGS_OTHER} ${WEBPMUX_CFLAGS_OTHER})" )
198
177
replace_in_file (self , cmakelists_src , "${WEBP_LIBRARIES}" , "${WEBP_LIBRARIES} ${WEBPMUX_LIBRARIES}" )
178
+ if Version (self .version ) >= "1.79.0" :
179
+ replace_in_file (self , cmakelists , "if(NOT WEBPMUX)" , "if(0)" )
180
+ if not self .options .with_webp :
181
+ replace_in_file (self , cmakelists_src , "if (WEBP_FOUND)" , "if(0)" )
182
+ replace_in_file (self , cmake_configure , "if (WEBP_FOUND)" , "if(0)" )
199
183
200
184
# Remove detection of fmemopen() on macOS < 10.13
201
185
# CheckFunctionExists will find it in the link library.
0 commit comments