diff --git a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt index 1ecdd6500b5d4..6b15485a1b778 100644 --- a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt +++ b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt @@ -8,6 +8,7 @@ builtin_jpeg=ON builtin_lz4=ON builtin_lzma=ON builtin_png=ON +builtin_tiff=ON builtin_vdt=ON builtin_zlib=ON builtin_zstd=ON diff --git a/.github/workflows/root-ci-config/buildconfig/mac-beta.txt b/.github/workflows/root-ci-config/buildconfig/mac-beta.txt index 1e46b6fda2cc1..8fa352a9bf042 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac-beta.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac-beta.txt @@ -12,6 +12,7 @@ builtin_nlohmannjson=ON builtin_openssl=ON builtin_pcre=ON builtin_tbb=ON +builtin_tiff=ON builtin_unuran=ON builtin_vdt=ON builtin_xrootd=ON diff --git a/.github/workflows/root-ci-config/buildconfig/mac14.txt b/.github/workflows/root-ci-config/buildconfig/mac14.txt index 218a1943b2fd8..c5bfe2f8f8702 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac14.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac14.txt @@ -15,6 +15,7 @@ builtin_nlohmannjson=ON builtin_openssl=ON builtin_pcre=ON builtin_tbb=ON +builtin_tiff=ON builtin_unuran=ON builtin_vdt=ON builtin_xrootd=ON diff --git a/.github/workflows/root-ci-config/buildconfig/mac15.txt b/.github/workflows/root-ci-config/buildconfig/mac15.txt index 1f9f56452fbde..656b40f6eb6f5 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac15.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac15.txt @@ -11,6 +11,7 @@ builtin_nlohmannjson=ON builtin_openssl=ON builtin_pcre=ON builtin_tbb=ON +builtin_tiff=ON builtin_unuran=ON builtin_vdt=ON builtin_xrootd=ON diff --git a/.github/workflows/root-ci-config/buildconfig/mac26.txt b/.github/workflows/root-ci-config/buildconfig/mac26.txt index 1e46b6fda2cc1..8fa352a9bf042 100644 --- a/.github/workflows/root-ci-config/buildconfig/mac26.txt +++ b/.github/workflows/root-ci-config/buildconfig/mac26.txt @@ -12,6 +12,7 @@ builtin_nlohmannjson=ON builtin_openssl=ON builtin_pcre=ON builtin_tbb=ON +builtin_tiff=ON builtin_unuran=ON builtin_vdt=ON builtin_xrootd=ON diff --git a/.github/workflows/root-ci-config/buildconfig/windows10.txt b/.github/workflows/root-ci-config/buildconfig/windows10.txt index 7612010e21feb..5eaa076ea38a4 100644 --- a/.github/workflows/root-ci-config/buildconfig/windows10.txt +++ b/.github/workflows/root-ci-config/buildconfig/windows10.txt @@ -12,6 +12,7 @@ builtin_nlohmannjson=ON builtin_pcre=ON builtin_png=ON builtin_tbb=ON +builtin_tiff=ON builtin_unuran=ON builtin_xxhash=ON builtin_zlib=ON diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b092fe9f969b..a0e99ce7dc6d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,9 +409,6 @@ else() if(asimage) message(SEND_ERROR "minimal=ON is not compatible with asimage=ON. Consider setting instead gminimal=ON") endif() - if(asimage_tiff) - message(SEND_ERROR "minimal=ON is not compatible with asimage_tiff=ON. Consider setting instead gminimal=ON") - endif() if(x11) message(SEND_ERROR "minimal=ON is not compatible with x11=ON. Consider setting instead gminimal=ON") endif() diff --git a/builtins/libjpeg/CMakeLists.txt b/builtins/libjpeg/CMakeLists.txt index 7af532e2fa893..ce071818569f6 100644 --- a/builtins/libjpeg/CMakeLists.txt +++ b/builtins/libjpeg/CMakeLists.txt @@ -61,7 +61,7 @@ add_dependencies(JPEG::JPEG BUILTIN_LIBJPEG) # Set the canonical output of find_package according to # https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names -set(JPEG_INCLUDE_DIRS ${${ROOT_LIBJPEG_PREFIX}/include} PARENT_SCOPE) +set(JPEG_INCLUDE_DIRS ${ROOT_LIBJPEG_PREFIX}/include PARENT_SCOPE) set(JPEG_LIBRARIES ${ROOT_LIBJPEG_LIBRARY} PARENT_SCOPE) set(JPEG_FOUND TRUE PARENT_SCOPE) set(JPEG_VERSION ${ROOT_LIBJPEG_VERSION} PARENT_SCOPE) diff --git a/builtins/libtiff/CMakeLists.txt b/builtins/libtiff/CMakeLists.txt new file mode 100644 index 0000000000000..abd1f8c7474ae --- /dev/null +++ b/builtins/libtiff/CMakeLists.txt @@ -0,0 +1,120 @@ +# Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. +# All rights reserved. +# +# For the licensing terms see $ROOTSYS/LICENSE. +# For the list of contributors see $ROOTSYS/README/CREDITS. + +# **PLEASE UPDATE ALSO THE FOLLOWING LINE WHEN UPDATING THE VERSION** +# 18 Sep 2024, https://github.com/libsdl-org/libtiff/releases/tag/v4.7.0 +set(ROOT_LIBTIFF_VERSION 4.7.0) +set(ROOT_LIBTIFF_HASH "67160e3457365ab96c5b3286a0903aa6e78bdc44c4bc737d2e486bcecb6ba976") + +set(ROOT_LIBTIFF_PREFIX ${CMAKE_BINARY_DIR}/builtins/LIBTIFF-prefix) +if(MSVC) + if(winrtdebug) + set(LIBTIFF_POSTFIX d) + endif() + if(NOT CMAKE_GENERATOR MATCHES Ninja) + if(winrtdebug) + set(ROOT_LIBTIFF_BUILD_COMMAND_FLAGS "--config Debug") + else() + set(ROOT_LIBTIFF_BUILD_COMMAND_FLAGS "--config $,RelWithDebInfo,Release>") + endif() + endif() + set(ROOT_LIBTIFF_LIBRARY ${ROOT_LIBTIFF_PREFIX}/lib/tiff${LIBTIFF_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) +else() + set(ROOT_LIBTIFF_LIBRARY ${ROOT_LIBTIFF_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}tiff${CMAKE_STATIC_LIBRARY_SUFFIX}) +endif() + +# If zlib is not builtin, the string will be empty, nothing special to be +# done: we rely on libtiff CMake to find zlib. +# If zlib is builtin, we need to direct the builtin libtiff to it. +if(builtin_zlib) + set(ZLIB_ROOT_OPTION "-DZLIB_ROOT=${ROOT_ZLIB_PREFIX}") +endif() +if(builtin_zstd) + set(ZSTD_ROOT_OPTION "-DZSTD_ROOT=${ROOT_ZSTD_PREFIX}") +endif() +if(builtin_lzma) + set(LZMA_ROOT_OPTION "-DLIBLZMA_ROOT=${ROOT_LZMA_PREFIX}") +endif() +if(builtin_jpeg) + set(JPEG_ROOT_OPTION "-DJPEG_ROOT=${ROOT_LIBJPEG_PREFIX}") +endif() + +ExternalProject_Add( + BUILTIN_LIBTIFF + PREFIX ${ROOT_LIBTIFF_PREFIX} + URL ${lcgpackages}/tiff-${ROOT_LIBTIFF_VERSION}.tar.gz + URL_HASH SHA256=${ROOT_LIBTIFF_HASH} + CMAKE_ARGS -G ${CMAKE_GENERATOR} + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_INSTALL_LIBDIR=/lib + -DCMAKE_INSTALL_BINDIR=/lib + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_CXX_VISIBILITY_PRESET=hidden + -DCMAKE_C_VISIBILITY_PRESET=hidden + -DBUILD_SHARED_LIBS=OFF + -Dtiff-contrib=OFF + -Dtiff-docs=OFF + -Dtiff-opengl=OFF # if ON, link below to GL and dependency to builtin + -Dtiff-tests=OFF + -Dtiff-tools=OFF + -Dcxx=OFF # We do not need library tiffxx.a (C++ stream API library) + -Djpeg=ON + -Dlerc=OFF + -Dlibdeflate=OFF # if ON or unset, then you need to target link libs interface below + -Dpixarlog=OFF + -Dwebp=OFF + -DZLIB_LIBRARY=${ZLIB_LIBRARIES} + -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} + ${ZLIB_ROOT_OPTION} + -DZSTD_LIBRARY=${ZSTD_LIBRARIES} + -DZSTD_INCLUDE_DIR=${ZSTD_INCLUDE_DIRS} + ${ZSTD_ROOT_OPTION} + -DLIBLZMA_LIBRARY=${LZMA_LIBRARIES} + -DLIBLZMA_INCLUDE_DIR=${LZMA_INCLUDE_DIRS} + ${LZMA_ROOT_OPTION} + -DJPEG_LIBRARY=${JPEG_LIBRARIES} + -DJPEG_INCLUDE_DIR=${JPEG_INCLUDE_DIRS} + ${JPEG_ROOT_OPTION} + BUILD_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_LIBTIFF_BUILD_COMMAND_FLAGS} + INSTALL_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_LIBTIFF_BUILD_COMMAND_FLAGS} --target install + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + BUILD_BYPRODUCTS ${ROOT_LIBTIFF_LIBRARY} + TIMEOUT 600 +) + +file(MAKE_DIRECTORY ${ROOT_LIBTIFF_PREFIX}/include) +add_library(TIFF::TIFF IMPORTED STATIC GLOBAL) +set_target_properties(TIFF::TIFF PROPERTIES + IMPORTED_LOCATION ${ROOT_LIBTIFF_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_LIBTIFF_PREFIX}/include +) +add_dependencies(TIFF::TIFF BUILTIN_LIBTIFF) + +if(builtin_zlib) + add_dependencies(BUILTIN_LIBTIFF BUILTIN_ZLIB) +endif() +target_link_libraries(TIFF::TIFF INTERFACE ZLIB::ZLIB) +if(builtin_zstd) + add_dependencies(BUILTIN_LIBTIFF BUILTIN_ZSTD) +endif() +target_link_libraries(TIFF::TIFF INTERFACE ZSTD::ZSTD) +if(builtin_lzma) + add_dependencies(BUILTIN_LIBTIFF BUILTIN_LZMA) +endif() +target_link_libraries(TIFF::TIFF INTERFACE LibLZMA::LibLZMA) +if(builtin_jpeg) + add_dependencies(BUILTIN_LIBTIFF BUILTIN_LIBJPEG) +endif() +target_link_libraries(TIFF::TIFF INTERFACE JPEG::JPEG) + +# Set the canonical output of find_package according to +# https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names +set(TIFF_INCLUDE_DIRS ${ROOT_LIBTIFF_PREFIX}/include PARENT_SCOPE) +set(TIFF_LIBRARIES ${ROOT_LIBTIFF_LIBRARY} PARENT_SCOPE) +set(TIFF_FOUND TRUE PARENT_SCOPE) +set(TIFF_VERSION ${ROOT_LIBTIFF_VERSION} PARENT_SCOPE) diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index 7562c6118c30e..e796317323a7c 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -79,7 +79,6 @@ endfunction() ROOT_BUILD_OPTION(arrow OFF "Enable support for Apache Arrow") ROOT_BUILD_OPTION(asimage ON "Enable support for image processing via libAfterImage") -ROOT_BUILD_OPTION(asimage_tiff ON "Support TIFF in image processing (requires libtiff)") ROOT_BUILD_OPTION(asserts OFF "Enable asserts (defaults to ON for CMAKE_BUILD_TYPE=Debug and/or dev=ON)") ROOT_BUILD_OPTION(builtin_cfitsio OFF "Build CFITSIO internally (requires network)") ROOT_BUILD_OPTION(builtin_clang ON "Build bundled copy of Clang") @@ -104,6 +103,7 @@ ROOT_BUILD_OPTION(builtin_openui5 ON "Use openui5 bundle distributed with ROOT") ROOT_BUILD_OPTION(builtin_pcre OFF "Build bundled copy of PCRE") ROOT_BUILD_OPTION(builtin_png OFF "Build bundled copy of libpng") ROOT_BUILD_OPTION(builtin_tbb OFF "Build TBB internally (requires network)") +ROOT_BUILD_OPTION(builtin_tiff OFF "Build libtiff internally (requires network)") ROOT_BUILD_OPTION(builtin_unuran OFF "Build bundled copy of unuran [GPL]") ROOT_BUILD_OPTION(builtin_vdt OFF "Build VDT internally (requires network)") ROOT_BUILD_OPTION(builtin_xrootd OFF "Build XRootD internally (requires network)") @@ -206,7 +206,6 @@ endif() if(all) set(arrow_defvalue ON) set(asimage_defvalue ON) - set(asimage_tiff_defvalue ON) set(cefweb_defvalue ON) set(clad_defvalue ON) set(curl_defvalue ON) @@ -276,6 +275,7 @@ if(builtin_all) set(builtin_pcre_defvalue ON) set(builtin_png_defvalue ON) set(builtin_tbb_defvalue ON) + set(builtin_tiff_defvalue ON) # set(builtin_unuran_defvalue ON) (GPL) set(builtin_vdt_defvalue ON) set(builtin_xrootd_defvalue ON) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index 220f331595e3e..6760b99b21053 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -112,11 +112,12 @@ endforeach() if(asimage) ROOT_FIND_REQUIRED_DEP(GIF builtin_gif) ROOT_FIND_REQUIRED_DEP(JPEG builtin_jpeg) - # We cannot PNG here because while searching PNG, CMake will also find ZLIB. + # We cannot PNG/TIFF here because while searching, CMake will also find ZLIB. # If found, CMake will define the default variables and target: # see https://cmake.org/cmake/help/latest/module/FindZLIB.html). # For this reason, the check has to be put below, after ZLIB is searched for. #ROOT_FIND_REQUIRED_DEP(PNG builtin_png) + #ROOT_FIND_REQUIRED_DEP(TIFF builtin_tiff) endif() ROOT_FIND_REQUIRED_DEP(LZ4 builtin_lz4) ROOT_FIND_REQUIRED_DEP(LibLZMA builtin_lzma) @@ -175,6 +176,7 @@ if(asimage) # This check can be added only now because of the reasons explained above, where all # other required dependencies are checked. ROOT_FIND_REQUIRED_DEP(PNG builtin_png) + ROOT_FIND_REQUIRED_DEP(TIFF builtin_tiff) endif() #---Check for nlohmann/json.hpp--------------------------------------------------------- @@ -383,18 +385,12 @@ if(asimage) endif() list(APPEND ASEXTRA_LIBRARIES JPEG::JPEG) - if(asimage_tiff) - find_Package(TIFF) - if(TIFF_FOUND) - list(APPEND ASEXTRA_LIBRARIES TIFF::TIFF) - else() - if(fail-on-missing) - message(SEND_ERROR "libtiff required but not found. Please make sure it's installed on the system, or disable TIFF support with '-Dasimage_tiff=OFF', or set '-Dfail-on-missing=OFF' to automatically disable features") - else() - set(asimage_tiff OFF CACHE BOOL "Disabled because libtiff was not found" FORCE) - endif() - endif() + if(builtin_tiff) + add_subdirectory(builtins/libtiff) + get_target_property(TIFF_INCLUDE_DIR TIFF::TIFF INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(TIFF_LIBRARY_LOCATION TIFF::TIFF IMPORTED_LOCATION) endif() + list(APPEND ASEXTRA_LIBRARIES TIFF::TIFF) endif() #---Check for GSL library--------------------------------------------------------------- diff --git a/roottest/root/graf/simpleImages.C b/roottest/root/graf/simpleImages.C index f5762de05ba58..ec79ff0b38c0b 100644 --- a/roottest/root/graf/simpleImages.C +++ b/roottest/root/graf/simpleImages.C @@ -15,7 +15,7 @@ int simpleImages() TH1D h("myHisto", "The Title;the X;the Y", 64, -4, 4); h.FillRandom("gaus"); h.Draw(); - std::vector fileNames{"f.jpeg", "f.png", "f.gif", "f.bmp"}; // TIFF not always there: only ON if asimage_tiff and libtiff installed in system (it's not a builtin like jpeg, png, gif) + std::vector fileNames{"f.jpeg", "f.png", "f.gif", "f.bmp", "f.tiff"}; ImagesRAII iraii(fileNames); for (auto &&fileName : fileNames) { c.SaveAs(fileName.c_str()); diff --git a/roottest/root/graf/simpleImages.ref b/roottest/root/graf/simpleImages.ref index c303d4cc4b532..f19c721ddb2c2 100644 --- a/roottest/root/graf/simpleImages.ref +++ b/roottest/root/graf/simpleImages.ref @@ -2,4 +2,5 @@ Info in : jpg file f.jpeg has been created Info in : png file f.png has been created Info in : gif file f.gif has been created Info in : bmp file f.bmp has been created +Info in : tiff file f.tiff has been created (int) 0