conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
966 stars 1.77k forks source link

[package] libtiff/4.4.0: Static build broken on Windows in recent recipe revisions due to CMake toolchain cache variable handling #14206

Closed stevn closed 2 years ago

stevn commented 2 years ago

Description

There are a few different recipe revisions of libtiff/4.4.0 available on Conan Center. When building the newest one as static library on Windows, the shared library (.dll) is built instead.

This can be seen in the libtiff CMake log as the following entry:

--   Build shared libraries:             ON

For static build we want this to be OFF and expect to be able to achieve this by adding "-o libtiff:shared=False" to the Conan command.

Please note that the pre-built binaries downloaded from the conancenter are OK (they are static builds) as far as I know. So if you don't rebuild libtiff from source, it just downloads the correct static built binaries (.lib files for Windows) and everything works. But if you need to disable the jbig option for example to disable GPL code, you need to rebuild from source, which seems to be broken.

This recipe revision is the last one that works OK for static builds:

conan install libtiff/4.4.0@#ead8fa5576779b422347bd88743c710d -o libtiff:shared=False --build=libtiff

These recipe revisions are broken (producing .dll files on Windows):

conan install libtiff/4.4.0@ -o libtiff:shared=False --build=libtiff
conan install libtiff/4.4.0@#604133fe6dfacb0f213409b4395ceedc -o libtiff:shared=False --build=libtiff
conan install libtiff/4.4.0@#f2aa646af088f6d82b4670ba8125cb03 -o libtiff:shared=False --build=libtiff

Package and Environment Details

Conan profile

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
build_type=Debug
[options]
[conf]
[build_requires]
[env]

Steps to reproduce

conan install libtiff/4.4.0@ -o libtiff:shared=False -o libtiff:jbig=False --build=missing

Logs

Click to expand log ``` Microsoft Windows [Version 10.0.19044.2251] (c) Microsoft Corporation. All rights reserved. C:\wrk>set CONAN_USER_HOME=C:\wrk C:\wrk>conan config set general.revisions_enabled=1 C:\wrk>conan install libtiff/4.4.0@ -o libtiff:shared=False -o libtiff:jbig=False --build=missing -s:b compiler.version=16 -s:h compiler.version=16 Auto detecting your dev setup to initialize the default profile (C:\wrk\.conan\profiles\default) Found Visual Studio 17 Found gcc 8.3 Default settings os=Windows os_build=Windows arch=x86_64 arch_build=x86_64 compiler=Visual Studio compiler.version=17 build_type=Release *** You can change them in C:\wrk\.conan\profiles\default *** *** Or override with -s compiler='other' -s ...s*** WARN: Remotes registry file missing, creating default one in C:\wrk\.conan\remotes.json Configuration (profile_host): [settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=Visual Studio compiler.runtime=MD compiler.version=16 os=Windows os_build=Windows [options] libtiff:jbig=False libtiff:shared=False [build_requires] [env] Configuration (profile_build): [settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=Visual Studio compiler.runtime=MD compiler.version=16 os=Windows os_build=Windows [options] [build_requires] [env] libtiff/4.4.0: Not found in local cache, looking in remotes... libtiff/4.4.0: Trying with 'conancenter'... Downloading conanmanifest.txt completed [0.19k] Downloading conanfile.py completed [7.67k] Downloading conan_export.tgz completed [0.32k] Decompressing conan_export.tgz completed [0.00k] libtiff/4.4.0: Downloaded recipe revision 604133fe6dfacb0f213409b4395ceedc zlib/1.2.13: Not found in local cache, looking in remotes... zlib/1.2.13: Trying with 'conancenter'... Downloading conanmanifest.txt completed [0.28k] Downloading conanfile.py completed [4.04k] Downloading conan_export.tgz completed [0.29k] Decompressing conan_export.tgz completed [0.00k] zlib/1.2.13: Downloaded recipe revision 13c96f538b52e1600c40b88994de240f libdeflate/1.12: Not found in local cache, looking in remotes... libdeflate/1.12: Trying with 'conancenter'... Downloading conanmanifest.txt completed [0.19k] Downloading conanfile.py completed [4.91k] Downloading conan_export.tgz completed [0.35k] Decompressing conan_export.tgz completed [0.00k] libdeflate/1.12: Downloaded recipe revision 1bf16d0e3c7c43d8b44ebd368425b462 xz_utils/5.2.5: Not found in local cache, looking in remotes... xz_utils/5.2.5: Trying with 'conancenter'... Downloading conanmanifest.txt completed [0.10k] Downloading conanfile.py completed [11.03k] Downloading conan_export.tgz completed [0.23k] Decompressing conan_export.tgz completed [0.00k] xz_utils/5.2.5: Downloaded recipe revision 7315e0f635fed3f9a91b8bfd5456b72c libjpeg/9e: Not found in local cache, looking in remotes... libjpeg/9e: Trying with 'conancenter'... Downloading conanmanifest.txt completed [0.26k] Downloading conanfile.py completed [8.16k] Downloading conan_export.tgz completed [0.28k] Decompressing conan_export.tgz completed [0.00k] libjpeg/9e: Downloaded recipe revision 129230c05b9705a9bbd6724f5de8eb98 zstd/1.5.2: Not found in local cache, looking in remotes... zstd/1.5.2: Trying with 'conancenter'... Downloading conanmanifest.txt completed [0.20k] Downloading conanfile.py completed [3.65k] Downloading conan_export.tgz completed [0.29k] Decompressing conan_export.tgz completed [0.00k] zstd/1.5.2: Downloaded recipe revision 32ecc755aa20cb076cd7e851e3ad3f52 libwebp/1.2.4: Not found in local cache, looking in remotes... libwebp/1.2.4: Trying with 'conancenter'... Downloading conanmanifest.txt completed [0.18k] Downloading conanfile.py completed [5.72k] Downloading conan_export.tgz completed [0.28k] Decompressing conan_export.tgz completed [0.00k] libwebp/1.2.4: Downloaded recipe revision ea598b8eae9729538cffc84de170462f Installing package: libtiff/4.4.0 Requirements libdeflate/1.12 from 'conancenter' - Downloaded libjpeg/9e from 'conancenter' - Downloaded libtiff/4.4.0 from 'conancenter' - Downloaded libwebp/1.2.4 from 'conancenter' - Downloaded xz_utils/5.2.5 from 'conancenter' - Downloaded zlib/1.2.13 from 'conancenter' - Downloaded zstd/1.5.2 from 'conancenter' - Downloaded Packages libdeflate/1.12:3fb49604f9c2f729b85ba3115852006824e72cab - Download libjpeg/9e:3fb49604f9c2f729b85ba3115852006824e72cab - Download libtiff/4.4.0:6783500b4f0c78e0f2a6c78a711270cc09b59dec - Build libwebp/1.2.4:638042d3fd356128c913f5e725646a0c2af264c7 - Download xz_utils/5.2.5:3fb49604f9c2f729b85ba3115852006824e72cab - Download zlib/1.2.13:3fb49604f9c2f729b85ba3115852006824e72cab - Download zstd/1.5.2:72381fc5a05da7a9f5e4d254cd58aa074c20b053 - Download Installing (downloading, building) binaries... libdeflate/1.12: Retrieving package 3fb49604f9c2f729b85ba3115852006824e72cab from remote 'conancenter' Downloading conanmanifest.txt completed [0.22k] Downloading conaninfo.txt completed [0.43k] Downloading conan_package.tgz completed [60.50k] Decompressing conan_package.tgz completed [0.00k] libdeflate/1.12: Package installed 3fb49604f9c2f729b85ba3115852006824e72cab libdeflate/1.12: Downloaded package revision 93488f354325d0d52fed332ebf5e07b6 libjpeg/9e: Retrieving package 3fb49604f9c2f729b85ba3115852006824e72cab from remote 'conancenter' Downloading conanmanifest.txt completed [0.56k] Downloading conaninfo.txt completed [0.43k] Downloading conan_package.tgz completed [269.31k] Decompressing conan_package.tgz completed [0.00k] libjpeg/9e: Package installed 3fb49604f9c2f729b85ba3115852006824e72cab libjpeg/9e: Downloaded package revision 5139f5214cb2364a0ca735875c333254 libwebp/1.2.4: Retrieving package 638042d3fd356128c913f5e725646a0c2af264c7 from remote 'conancenter' Downloading conanmanifest.txt completed [0.63k] Downloading conaninfo.txt completed [0.56k] Downloading conan_package.tgz completed [555.49k] Decompressing conan_package.tgz completed [0.00k] libwebp/1.2.4: Package installed 638042d3fd356128c913f5e725646a0c2af264c7 libwebp/1.2.4: Downloaded package revision c455d00da184708eb0bae98563c40792 xz_utils/5.2.5: Retrieving package 3fb49604f9c2f729b85ba3115852006824e72cab from remote 'conancenter' Downloading conanmanifest.txt completed [1.05k] Downloading conaninfo.txt completed [0.43k] Downloading conan_package.tgz completed [334.69k] Decompressing conan_package.tgz completed [0.00k] xz_utils/5.2.5: Package installed 3fb49604f9c2f729b85ba3115852006824e72cab xz_utils/5.2.5: Downloaded package revision 016a8982e7c3311501a775d00099543e zlib/1.2.13: Retrieving package 3fb49604f9c2f729b85ba3115852006824e72cab from remote 'conancenter' Downloading conanmanifest.txt completed [0.25k] Downloading conaninfo.txt completed [0.43k] Downloading conan_package.tgz completed [97.10k] Decompressing conan_package.tgz completed [0.00k] zlib/1.2.13: Package installed 3fb49604f9c2f729b85ba3115852006824e72cab zlib/1.2.13: Downloaded package revision af3348b4caca1d82c42531a352a4cc25 zstd/1.5.2: Retrieving package 72381fc5a05da7a9f5e4d254cd58aa074c20b053 from remote 'conancenter' Downloading conanmanifest.txt completed [0.31k] Downloading conaninfo.txt completed [0.46k] Downloading conan_package.tgz completed [378.13k] Decompressing conan_package.tgz completed [0.00k] zstd/1.5.2: Package installed 72381fc5a05da7a9f5e4d254cd58aa074c20b053 zstd/1.5.2: Downloaded package revision 68b8097e07c66d6a1ca79244fc28d802 Downloading conan_sources.tgz completed [1.00k] Decompressing conan_sources.tgz completed [0.00k] libtiff/4.4.0: Configuring sources in C:\wrk\.conan\data\libtiff\4.4.0\_\_\source\src Downloading tiff-4.4.0.tar.gz completed [2774.49k] libtiff/4.4.0: /4.4.0: libtiff/4.4.0: libtiff/4.4.0: Copying sources to build folder libtiff/4.4.0: Building your package in C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec libtiff/4.4.0: Generator txt created conanbuildinfo.txt libtiff/4.4.0: Calling generate() libtiff/4.4.0: Preset 'default' added to CMakePresets.json. Invoke it manually using 'cmake --preset default' libtiff/4.4.0: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build\generators\conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW' libtiff/4.4.0: Aggregating env generators libtiff/4.4.0: Calling build() libtiff/4.4.0: Apply patch (conan): CMake: robust handling of dependencies libtiff/4.4.0: CMake command: cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\src" -- Building tiff version 4.4.0 -- libtiff library version 5.8.0 -- libtiff build date: 20221115 -- Using Conan toolchain: C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/build/generators/conan_toolchain.cmake -- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044. -- The C compiler identification is MSVC 19.29.30137.0 -- The CXX compiler identification is MSVC 19.29.30137.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test C_FLAG_W3 -- Performing Test C_FLAG_W3 - Success -- Performing Test HAVE_LD_VERSION_SCRIPT -- Performing Test HAVE_LD_VERSION_SCRIPT - Failed -- 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 - found -- Looking for strings.h -- Looking for strings.h - not found -- Looking for sys/time.h -- Looking for sys/time.h - not found -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for unistd.h -- Looking for unistd.h - not found -- Looking for getopt -- Looking for getopt - not found -- Looking for optarg -- Looking for optarg - not found -- Looking for mmap -- Looking for mmap - not found -- Looking for setmode -- Looking for setmode - not found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of size_t -- Check size of size_t - done -- Conan: Target declared 'ZLIB::ZLIB' -- Conan: Target declared 'libdeflate::libdeflate' -- Conan: Target declared 'JPEG::JPEG' -- Could NOT find jbig (missing: jbig_DIR) -- Could NOT find LERC (missing: LERC_LIBRARY LERC_INCLUDE_DIR) -- Conan: Target declared 'LibLZMA::LibLZMA' -- Conan: Including build module from 'C:/wrk/.conan/data/xz_utils/5.2.5/_/_/package/3fb49604f9c2f729b85ba3115852006824e72cab/lib/cmake/conan-official-xz_utils-variables.cmake' -- Conan: Component target declared 'zstd::libzstd_static' -- Conan: Component target declared 'WebP::webpdecoder' -- Conan: Component target declared 'WebP::webp' -- Conan: Component target declared 'WebP::webpdemux' -- Conan: Component target declared 'WebP::libwebpmux' -- Conan: Target declared 'libwebp::libwebp' -- Found OpenGL: opengl32 found components: OpenGL -- Found PkgConfig: C:/Strawberry/perl/bin/pkg-config.bat (found version "0.26") -- Checking for module 'glut' -- -- Could NOT find GLUT (missing: GLUT_glut_LIBRARY) -- 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 - found -- Found CMath: TRUE -- -- Libtiff is now configured for Windows-10.0.19044 -- -- Installation directory: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec -- Documentation directory: share/doc/tiff -- C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe -- C++ compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe -- Build shared libraries: ON -- Enable linker symbol versioning: FALSE -- Support Microsoft Document Imaging: ON -- Use win32 IO: ON -- -- 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:1 Support:TRUE -- libdeflate support: Requested:True Availability: Support:TRUE -- Pixar log-format algorithm: Requested:ON Availability:1 Support:TRUE -- JPEG support: Requested:ON Availability:1 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: 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: Support:TRUE -- -- C++ support: True (requested) TRUE (availability) -- -- OpenGL support: FALSE -- -- Configuring done -- Generating done -- Build files have been written to: C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/build libtiff/4.4.0: CMake command: cmake --build "C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build" --config Release Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Checking Build System Building Custom Rule C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/src/port/CMa keLists.txt getopt.c port.vcxproj -> C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build\port\Releas e\port.lib Building Custom Rule C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/src/libtiff/ CMakeLists.txt tif_aux.c tif_close.c tif_codec.c tif_color.c tif_compress.c tif_dir.c tif_dirinfo.c tif_dirread.c tif_dirwrite.c tif_dumpmode.c tif_error.c tif_extension.c tif_fax3.c tif_fax3sm.c tif_flush.c tif_getimage.c tif_jbig.c tif_jpeg.c tif_jpeg_12.c tif_lerc.c tif_luv.c tif_lzma.c tif_lzw.c tif_next.c tif_ojpeg.c tif_open.c tif_packbits.c tif_pixarlog.c tif_predict.c tif_print.c tif_read.c tif_strip.c tif_swab.c tif_thunder.c tif_tile.c tif_version.c tif_warning.c tif_webp.c tif_write.c tif_zip.c tif_zstd.c tif_win32.c Creating library C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/build/libtiff /Release/tiff.lib and object C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/buil d/libtiff/Release/tiff.exp tiff.vcxproj -> C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build\libtiff\Rel ease\tiff.dll Building Custom Rule C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/src/libtiff/ CMakeLists.txt mkg3states.c getopt.c mkg3states.vcxproj -> C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build\libti ff\Release\mkg3states.exe Building Custom Rule C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/src/libtiff/ CMakeLists.txt tif_stream.cxx Auto build dll exports Creating library C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/build/libtiff /Release/tiffxx.lib and object C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/bu ild/libtiff/Release/tiffxx.exp tiffxx.vcxproj -> C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build\libtiff\R elease\tiffxx.dll Building Custom Rule C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/src/CMakeLis ts.txt libtiff/4.4.0: Package '6783500b4f0c78e0f2a6c78a711270cc09b59dec' built libtiff/4.4.0: Build folder C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build libtiff/4.4.0: Generated conaninfo.txt libtiff/4.4.0: Generated conanbuildinfo.txt libtiff/4.4.0: Generating the package libtiff/4.4.0: Package folder C:\wrk\.conan\data\libtiff\4.4.0\_\_\package\6783500b4f0c78e0f2a6c78a711270cc09b59dec libtiff/4.4.0: Calling package() libtiff/4.4.0: Copied 1 file: COPYRIGHT libtiff/4.4.0: CMake command: cmake --install "C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build" --config Release --prefix "C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec" -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/lib/pkgconfig/libtiff-4.pc -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/lib/tiff.lib -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/bin/tiff.dll -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/include/tiff.h -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/include/tiffio.h -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/include/tiffvers.h -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/include/tiffconf.h -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/lib/cmake/tiff/TiffTargets.cmake -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/lib/cmake/tiff/TiffTargets-release.cmake -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/lib/tiffxx.lib -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/bin/tiffxx.dll -- Installing: C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec/include/tiffio.hxx libtiff/4.4.0 package(): Packaged 2 '.dll' files: tiff.dll, tiffxx.dll libtiff/4.4.0 package(): Packaged 4 '.h' files: tiff.h, tiffconf.h, tiffio.h, tiffvers.h libtiff/4.4.0 package(): Packaged 1 '.hxx' file: tiffio.hxx libtiff/4.4.0 package(): Packaged 2 '.lib' files: tiff.lib, tiffxx.lib libtiff/4.4.0 package(): Packaged 1 file: COPYRIGHT libtiff/4.4.0: Package '6783500b4f0c78e0f2a6c78a711270cc09b59dec' created libtiff/4.4.0: Created package revision b5495f50bf24160a9baaa8bde3905b03 Aggregating env generators C:\wrk> ```
stevn commented 2 years ago

Conan logs show shared is being set to OFF:

-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF

But later in the libtiff CMake, it is set to ON:

--   Build shared libraries:             ON
stevn commented 2 years ago

The CMake cache variable is set to ON by default here by libtiff's root CMakeLists.txt:

https://gitlab.com/libtiff/libtiff/-/blob/v4.4.0/CMakeLists.txt#L43

set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")

In the Conan toolchain file this is set to OFF:

C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\build\generators\conan_toolchain.cmake

message(STATUS "Conan toolchain: Setting BUILD_SHARED_LIBS = OFF")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
stevn commented 2 years ago

https://cmake.org/cmake/help/latest/command/set.html

Sets the given cache (cache entry). Since cache entries are meant to provide user-settable values this does not overwrite existing cache entries by default. Use the FORCE option to overwrite existing entries.

So it seems to boil down to the question in which order these CMake set commands are executed.

The relevant CMake command is:

libtiff/4.4.0: CMake command: cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="C:/wrk/.conan/data/libtiff/4.4.0/_/_/build/6783500b4f0c78e0f2a6c78a711270cc09b59dec/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/wrk/.conan/data/libtiff/4.4.0/_/_/package/6783500b4f0c78e0f2a6c78a711270cc09b59dec" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\wrk\.conan\data\libtiff\4.4.0\_\_\build\6783500b4f0c78e0f2a6c78a711270cc09b59dec\src"

The CMake documentation indicates that the CMAKE_TOOLCHAIN_FILE is interpreted "early". It is unclear what "early" means exactly.

https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html

It is the path to a file which is read early in the CMake run and which specifies locations for compilers and toolchain utilities, and other target platform and compiler related information.

Here the usage of cache variables via CMake toolchain files is discouraged:

https://discourse.cmake.org/t/configurable-in-cmake-toolchain-file-files/1122/3

Because it is a cache variable, it will only set the value of SOME_VAR if it is not already set. It is not wrong to do so, but usually not the best approach. I tend to only need to set plain variables in toolchain files.

stevn commented 2 years ago

https://stackoverflow.com/questions/30503631/cmake-in-which-order-are-files-parsed-cache-toolchain-etc

The project() command trigger most of CMake's detection magic (including reading from the Toolchain.txt file).

stevn commented 2 years ago

It seems to me that the CMake toolchain file is being interpreted on the first project() call (line 52). However, just before that project() call, the libtiff root CMakeLists.txt is setting the cache variable (line 43), which means that the set() call in the toolchain file has no effect.

CMakeLists.txt:

set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")

# Disable deprecated features to ensure clean build
add_definitions(-DTIFF_DISABLE_DEPRECATED)

# Project definition
set(CMAKE_C_STANDARD 99)
project(tiff
    VERSION "${LIBTIFF_VERSION}"
    LANGUAGES C CXX)`

So building static libtiff 4.4.0 with CMake toolchain files (which set the cache variable BUILD_SHARED_LIBS without FORCE) seems to be broken. Maybe this should be brought to the attention of the libtiff developers.

stevn commented 2 years ago

Seems like there are some other people having similar problems:

https://gitlab.kitware.com/cmake/cmake/-/issues/23237 https://github.com/conan-io/conan/issues/7831 https://github.com/conan-io/conan/issues/7832 https://github.com/conan-io/conan/pull/8124 https://github.com/conan-io/conan/issues/11224 https://github.com/conan-io/conan/projects/35#card-47728228 https://github.com/conan-io/conan/issues/11840 https://github.com/conan-io/conan/pull/12401

SpaceIm commented 2 years ago

will be fixed by https://github.com/conan-io/conan-center-index/pull/14210

The root cause is that in upstream CMakeLists, there is set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries"), so CMakeToolchain in conan < 1.54.0 can't handle this case properly. Moreover, even conan 1.54.0 (https://github.com/conan-io/conan/pull/12401) can't work out of the box because this set(BUILD_SHARED_LIBS is put before project(). The only solution is to pass -DBUILD_SHARED_LIBS=OFF in CMake command line (so tc.cache_variables in CMakeToolchain).

stevn commented 2 years ago

Might already be fixed in libtiff master branch:

https://gitlab.com/libtiff/libtiff/-/blob/master/CMakeLists.txt#L51