Repository: conan-io/conan-center-index

Issue:
[package] libtiff/4.3.0: jbig cannot be disabled
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **libtiff/4.3.0**
  * Operating System+version: **Linux Mint 20.02**
  * Compiler+version: **GCC 9**
  * Conan version: **conan 1.40.0**
  * Python version: **Python 3.9.7**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
Configuration for profile default:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=9
compiler.libcxx=libstdc++
build_type=Release
[options]
[conf]
[build_requires]
[env]

```


### Steps to reproduce (Include if Applicable)
```
conan install libtiff/4.3.0@_/_ -o libtiff:jbig=False --build=libtiff
```


### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=9
os=Linux
os_build=Linux
[options]
libtiff:jbig=False
[build_requires]
[env]

libtiff/4.3.0: Forced build from source
Installing package: libtiff/4.3.0
Requirements
    libdeflate/1.8 from local cache - Cache
    libjpeg/9d from local cache - Cache
    libtiff/4.3.0 from local cache - Cache
    libwebp/1.2.0 from local cache - Cache
    xz_utils/5.2.5 from local cache - Cache
    zlib/1.2.11 from local cache - Cache
    zstd/1.5.0 from local cache - Cache
Packages
    libdeflate/1.8:6af9cc7cb931c5ad942174fd7838eb655717c709 - Cache
    libjpeg/9d:6af9cc7cb931c5ad942174fd7838eb655717c709 - Cache
    libtiff/4.3.0:2faaf6b4e1c464faee72d30aac84fe5f4bba074e - Build
    libwebp/1.2.0:034afc24309e6fc60dbccb1dab5b0f9cad6ec656 - Cache
    xz_utils/5.2.5:6af9cc7cb931c5ad942174fd7838eb655717c709 - Cache
    zlib/1.2.11:6af9cc7cb931c5ad942174fd7838eb655717c709 - Cache
    zstd/1.5.0:6af9cc7cb931c5ad942174fd7838eb655717c709 - Cache

Installing (downloading, building) binaries...
libdeflate/1.8: Already installed!
libjpeg/9d: Already installed!
libwebp/1.2.0: Already installed!
xz_utils/5.2.5: Already installed!
zlib/1.2.11: Already installed!
zstd/1.5.0: Already installed!
libtiff/4.3.0: WARN: Build folder is dirty, removing it: /home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e
libtiff/4.3.0: Copying sources to build folder
libtiff/4.3.0: Building your package in /home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e
libtiff/4.3.0: Generator cmake created conanbuildinfo.cmake
libtiff/4.3.0: Generator cmake_find_package created FindZLIB.cmake
libtiff/4.3.0: Generator cmake_find_package created Findlibdeflate.cmake
libtiff/4.3.0: Generator cmake_find_package created FindLibLZMA.cmake
libtiff/4.3.0: Generator cmake_find_package created FindJPEG.cmake
libtiff/4.3.0: Generator cmake_find_package created Findzstd.cmake
libtiff/4.3.0: Generator cmake_find_package created FindWebP.cmake
libtiff/4.3.0: Aggregating env generators
libtiff/4.3.0: Calling build()
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /home/arimil/miniconda3/envs/firestorm/bin/cc
-- Check for working C compiler: /home/arimil/miniconda3/envs/firestorm/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- Conan: Compiler GCC>=5, checking major version 9
-- Conan: Checking correct version: 9
-- Conan: C++ stdlib: libstdc++
-- Building tiff version 4.3.0
-- libtiff library version 5.7.0
-- libtiff build date: 20210913
-- Performing Test C_FLAG_Wall
-- Performing Test C_FLAG_Wall - Success
-- Performing Test C_FLAG_Winline
-- Performing Test C_FLAG_Winline - Success
-- Performing Test C_FLAG_Wformat_security
-- Performing Test C_FLAG_Wformat_security - Success
-- Performing Test C_FLAG_Wpointer_arith
-- Performing Test C_FLAG_Wpointer_arith - Success
-- Performing Test C_FLAG_Wdisabled_optimization
-- Performing Test C_FLAG_Wdisabled_optimization - Success
-- Performing Test C_FLAG_Wno_unknown_pragmas
-- Performing Test C_FLAG_Wno_unknown_pragmas - Success
-- Performing Test C_FLAG_fstrict_aliasing
-- Performing Test C_FLAG_fstrict_aliasing - Success
-- Performing Test HAVE_LD_VERSION_SCRIPT
-- Performing Test HAVE_LD_VERSION_SCRIPT - Success
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for io.h
-- Looking for io.h - not found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for getopt
-- Looking for getopt - found
-- Looking for optarg
-- Looking for optarg - found
-- Looking for mmap
-- Looking for mmap - found
-- Looking for setmode
-- Looking for setmode - not found
-- Check size of size_t
-- Check size of size_t - done
-- Conan: Using autogenerated FindZLIB.cmake
-- Found ZLIB: 1.2.11 (found version "1.2.11") 
-- Library z found /home/arimil/.conan/data/zlib/1.2.11/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libz.a
-- Found: /home/arimil/.conan/data/zlib/1.2.11/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libz.a
-- Found Deflate: /home/arimil/.conan/data/libdeflate/1.8/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libdeflate.a  
-- Conan: Using autogenerated FindJPEG.cmake
-- Found JPEG: 9d (found version "9d") 
-- Library jpeg found /home/arimil/.conan/data/libjpeg/9d/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libjpeg.a
-- Found: /home/arimil/.conan/data/libjpeg/9d/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libjpeg.a
CMake Error at source_subfolder/cmake/FindJBIG.cmake:1 (include):
  include could not find load file:

    /home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e/ConanFindjbig.cmake
Call Stack (most recent call first):
  source_subfolder/cmake/JBIGCodec.cmake:30 (find_package)
  source_subfolder/CMakeLists.txt:101 (include)


-- Could NOT find JBIG (missing: JBIG_LIBRARY JBIG_INCLUDE_DIR) 
-- Could NOT find LERC (missing: LERC_LIBRARY LERC_INCLUDE_DIR) 
-- Conan: Using autogenerated FindLibLZMA.cmake
-- Found LibLZMA: 5.2.5 (found version "5.2.5") 
-- Library lzma found /home/arimil/.conan/data/xz_utils/5.2.5/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/liblzma.a
-- Found: /home/arimil/.conan/data/xz_utils/5.2.5/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/liblzma.a
-- Conan: Using autogenerated Findzstd.cmake
-- Found zstd: 1.5.0 (found version "1.5.0") 
-- Library zstd found /home/arimil/.conan/data/zstd/1.5.0/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libzstd.a
-- Found: /home/arimil/.conan/data/zstd/1.5.0/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libzstd.a
-- Library zstd found /home/arimil/.conan/data/zstd/1.5.0/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libzstd.a
-- Found: /home/arimil/.conan/data/zstd/1.5.0/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libzstd.a
-- Found ZSTD: /home/arimil/.conan/data/zstd/1.5.0/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/libzstd.a (found version "1.5.0") 
-- Looking for ZSTD_decompressStream
-- Looking for ZSTD_decompressStream - found
-- Conan: Using autogenerated FindWebP.cmake
-- Found WebP: 1.2.0 (found version "1.2.0") 
-- Library webpdecoder found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdecoder.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdecoder.a
-- Library webpdemux found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdemux.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdemux.a
-- Library webpmux found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpmux.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpmux.a
-- Library webp found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebp.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebp.a
-- Library webp found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebp.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebp.a
-- Library webpmux found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpmux.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpmux.a
-- Library webpdemux found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdemux.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdemux.a
-- Library webpdecoder found /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdecoder.a
-- Found: /home/arimil/.conan/data/libwebp/1.2.0/_/_/package/034afc24309e6fc60dbccb1dab5b0f9cad6ec656/lib/libwebpdecoder.a
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so  found components: OpenGL 
-- Could NOT find GLUT (missing: GLUT_glut_LIBRARY GLUT_INCLUDE_DIR) 
-- Looking for GL/gl.h
-- Looking for GL/gl.h - not found
-- Looking for GL/glu.h
-- Looking for GL/glu.h - not found
-- Looking for GL/glut.h
-- Looking for GL/glut.h - not found
-- Looking for GLUT/glut.h
-- Looking for GLUT/glut.h - not found
-- Looking for OpenGL/gl.h
-- Looking for OpenGL/gl.h - not found
-- Looking for OpenGL/glu.h
-- Looking for OpenGL/glu.h - not found
-- Looking for pow
-- Looking for pow - not found
-- Looking for pow
-- Looking for pow - found
-- Found CMath: TRUE  
-- 
-- Libtiff is now configured for Linux-5.11.0-34-generic
-- 
--   Installation directory:             /home/arimil/.conan/data/libtiff/4.3.0/_/_/package/2faaf6b4e1c464faee72d30aac84fe5f4bba074e
--   Documentation directory:            /home/arimil/.conan/data/libtiff/4.3.0/_/_/package/2faaf6b4e1c464faee72d30aac84fe5f4bba074e/share/doc/tiff
--   C compiler:                         /home/arimil/miniconda3/envs/firestorm/bin/cc
--   C++ compiler:                       /usr/bin/c++
--   Build shared libraries:             OFF
--   Enable linker symbol versioning:    TRUE
--   Support Microsoft Document Imaging: ON
--   Use win32 IO:                       OFF
-- 
--  Support for internal codecs:
--   CCITT Group 3 & 4 algorithms:       ON
--   Macintosh PackBits algorithm:       ON
--   LZW algorithm:                      ON
--   ThunderScan 4-bit RLE algorithm:    ON
--   NeXT 2-bit RLE algorithm:           ON
--   LogLuv high dynamic range encoding: ON
-- 
--  Support for external codecs:
--   ZLIB support:                       Requested:True Availability:TRUE Support:TRUE
--   libdeflate support:                 Requested:True Availability:TRUE Support:TRUE
--   Pixar log-format algorithm:         Requested:ON Availability:TRUE Support:TRUE
--   JPEG support:                       Requested:True Availability:TRUE Support:TRUE
--   Old JPEG support:                   Requested:ON Availability:TRUE Support:TRUE
--   JPEG 8/12 bit dual mode:            Requested:OFF Availability:FALSE Support:FALSE
--   ISO JBIG support:                   Requested:False Availability:FALSE Support:FALSE
--   LERC support:                       Requested:OFF Availability:FALSE Support:FALSE
--   LZMA2 support:                      Requested:True Availability:TRUE Support:TRUE
--   ZSTD support:                       Requested:True Availability:TRUE Support:TRUE
--   WEBP support:                       Requested:True Availability:TRUE Support:TRUE
-- 
--   C++ support:                        True (requested) TRUE (availability)
-- 
--   OpenGL support:                     FALSE
-- 
-- Configuring incomplete, errors occurred!
See also "/home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e/build_subfolder/CMakeFiles/CMakeOutput.log".
See also "/home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e/build_subfolder/CMakeFiles/CMakeError.log".
libtiff/4.3.0: 
libtiff/4.3.0: ERROR: Package '2faaf6b4e1c464faee72d30aac84fe5f4bba074e' build failed
libtiff/4.3.0: WARN: Build folder /home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e
ERROR: libtiff/4.3.0: Error in build() method, line 165
        cmake = self._configure_cmake()
while calling '_configure_cmake', line 160
        self._cmake.configure(build_folder=self._build_subfolder)
        ConanException: Error 1 while executing cd '/home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e/build_subfolder' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="gcc" -DCONAN_COMPILER_VERSION="9" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/home/arimil/.conan/data/libtiff/4.3.0/_/_/package/2faaf6b4e1c464faee72d30aac84fe5f4bba074e" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_MODULE_PATH="/home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Dlzma="True" -Djpeg="True" -Djbig="False" -Dzlib="True" -Dlibdeflate="True" -Dzstd="True" -Dwebp="True" -Dcxx="True" -Wno-dev '/home/arimil/.conan/data/libtiff/4.3.0/_/_/build/2faaf6b4e1c464faee72d30aac84fe5f4bba074e'
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/libtiff/all/conanfile.py b/recipes/libtiff/all/conanfile.py
--- a/recipes/libtiff/all/conanfile.py
+++ b/recipes/libtiff/all/conanfile.py
@@ -105,15 +105,22 @@ def source(self):
                   destination=self._source_subfolder, strip_root=True)
 
     def _patch_sources(self):
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
+            tools.patch(**patch)
+
         # Rename the generated Findjbig.cmake and Findzstd.cmake to avoid case insensitive conflicts with FindJBIG.cmake and FindZSTD.cmake on Windows
         if self.options.jbig:
             tools.rename(os.path.join(self.build_folder, "Findjbig.cmake"),
                          os.path.join(self.build_folder, "ConanFindjbig.cmake"))
-        if self.options.get_safe("zstd"):
-            tools.rename(os.path.join(self.build_folder, "Findzstd.cmake"),
-                         os.path.join(self.build_folder, "ConanFindzstd.cmake"))
-        for patch in self.conan_data.get("patches", {}).get(self.version, []):
-            tools.patch(**patch)
+        else:
+            os.remove(os.path.join(self.build_folder, self._source_subfolder, "cmake", "FindJBIG.cmake"))
+        if self._has_zstd_option:
+            if self.options.zstd:
+                tools.rename(os.path.join(self.build_folder, "Findzstd.cmake"),
+                             os.path.join(self.build_folder, "ConanFindzstd.cmake"))
+            else:
+                os.remove(os.path.join(self.build_folder, self._source_subfolder, "cmake", "FindZSTD.cmake"))
+
         if self.options.shared and self.settings.compiler == "Visual Studio":
             # https://github.com/Microsoft/vcpkg/blob/master/ports/tiff/fix-cxx-shared-libs.patch
             tools.replace_in_file(os.path.join(self._source_subfolder, "libtiff", "CMakeLists.txt"),


Test patch: