@@ -293,6 +293,8 @@ set(CBF_USE_ULP $ENV{CBF_USE_ULP})
293293set (CBF_M4FLAGS_ENV $ENV{M4FLAGS} )
294294set (CBF_HDF5REGISTER_MANUAL_ENV $ENV{CBF_HDF5REGISTER_MANUAL} )
295295
296+ option (BUILD_SHARED_LIBS "Build using shared libraries" OFF )
297+
296298option (CBF_ENABLE_FORTRAN "Enable Fortran 90" ON )
297299if (CBF_ENABLE_FORTRAN)
298300 include (CheckLanguage)
@@ -342,15 +344,6 @@ if (NOT CMAKE_BUILD_TYPE)
342344 FORCE)
343345endif (NOT CMAKE_BUILD_TYPE )
344346
345- #
346- # Favor static libraries
347- #
348- IF (WIN32 )
349- SET (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES} )
350- ELSE (WIN32 )
351- SET (CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES} )
352- ENDIF (WIN32 )
353-
354347
355348#
356349# Macros
@@ -437,19 +430,18 @@ set(MINICBF_TEST "${CBFlib_SOURCE_DIR}/minicbf_test" CACHE STRING "")
437430set (GRAPHICS "${CBFlib_SOURCE_DIR} /html_graphics" CACHE STRING "" )
438431
439432
440- #
441- # Definition to get a version of tifflib to support tiff2cbf
442- #
443- set (CBF_TIFF "tiff-4.0.6_rev_3Nov16" )
444- set (TIFF_INSTALL_DIR "${CMAKE_BINARY_DIR} /${CBF_TIFF} " )
445-
446-
447433#
448434# CQRlib
449435set (CBF_CQRLIB "cqrlib-1.1.4" )
450436set (CBF_CQRLIB_URL "https://github.com/yayahjb/cqrlib/archive/refs/tags/CQRlib-1.1.4.tar.gz" )
451437set (CQRLIB_INSTALL_DIR "${CMAKE_BINARY_DIR} /${CBF_CQRLIB} " )
452438
439+ include (FetchContent)
440+ find_program (PATCH patch)
441+
442+ fetchcontent_declare(tiff
443+ URL "http://downloads.sf.net/cbflib/tiff-4.0.6_rev_3Nov16.tar.gz"
444+ URL_HASH MD5=594d1811ce715f7d5ec586bf5e0c4732)
453445
454446#
455447# Definitions to get a version of HDF5
@@ -491,7 +483,6 @@ set(CBF_REGEX "regex-20090805")
491483set (CBF_PCRE "pcre-8.33" )
492484set (CBF_REGEXURL "http://downloads.sf.net/cbflib/${CBF_REGEX} .tar.gz" )
493485set (CBF_PCREURL "http://downloads.sf.net/cbflib/${CBF_PCRE} .tar.gz" )
494- set (CBF_TIFFURL "http://downloads.sf.net/cbflib/${CBF_TIFF} .tar.gz" )
495486set (CBF_HDF5URL "http://downloads.sf.net/cbflib/${CBF_HDF5} .tar.gz" )
496487
497488
@@ -512,22 +503,26 @@ include(ExternalProject)
512503# TIFF
513504#
514505# LibTIFF to support tiff2cbf.
515- find_program (PATCH patch)
516- ExternalProject_Add(${CBF_TIFF}
517- URL "${CBF_TIFFURL} "
518- CMAKE_ARGS
519- "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} "
520- "-DCMAKE_INSTALL_BINDIR:PATH=${TIFF_INSTALL_DIR} /bin"
521- "-DCMAKE_INSTALL_DATAROOTDIR:PATH=${TIFF_INSTALL_DIR} /share/libtiff"
522- "-DCMAKE_INSTALL_INCLUDEDIR:PATH=${TIFF_INSTALL_DIR} /include/libtiff"
523- "-DCMAKE_INSTALL_LIBDIR:PATH=${TIFF_INSTALL_DIR} /lib"
524- "-DCMAKE_INSTALL_PREFIX:PATH=${TIFF_INSTALL_DIR} " )
525- file (MAKE_DIRECTORY "${TIFF_INSTALL_DIR} /include/libtiff" )
526- add_library (tiff SHARED IMPORTED )
527- add_dependencies (tiff ${CBF_TIFF} )
528- set_target_properties (tiff PROPERTIES
529- IMPORTED_LOCATION "${TIFF_INSTALL_DIR} /lib/libtiff${CMAKE_SHARED_LIBRARY_SUFFIX} "
530- INTERFACE_INCLUDE_DIRECTORIES "${TIFF_INSTALL_DIR} /include/libtiff" )
506+ set (CBF_WITH_LIBTIFF ON CACHE BOOL
507+ "Link against internally built LibTIFF library" )
508+ mark_as_advanced (CBF_WITH_LIBTIFF)
509+
510+ if (CBF_WITH_LIBTIFF)
511+ # The first LibTIFF at https://gitlab.com/libtiff/libtiff with
512+ # native CMake support seems to be 4.0.5. The first version that
513+ # builds on current MSYS2 is 4.0.9.
514+ #
515+ # 4.0.3-rev-29Sep13 appears to have CMakeLists.txt patched in but
516+ # fails on MSYS2: multiple definition of ua_wcsicmp.
517+ set (tiff-contrib OFF )
518+ set (tiff-docs OFF )
519+ set (tiff-tests OFF )
520+ set (tiff-tools OFF )
521+ fetchcontent_makeavailable(tiff)
522+ else ()
523+ find_package (TIFF REQUIRED)
524+ add_library (tiff ALIAS TIFF::TIFF)
525+ endif ()
531526
532527
533528ExternalProject_add(
@@ -653,8 +648,6 @@ endif ()
653648#
654649# Verify the checksums. The --binary option appears to be required
655650# for patching the test data on MSYS2.
656- include (FetchContent)
657-
658651fetchcontent_declare(data_input
659652 URL "http://downloads.sf.net/cbflib/CBFlib_${PROJECT_VERSION} _Data_Files_Input.tar.gz"
660653 URL_HASH MD5=f98ae4214b3e57acb42437ea4b685c4d)
0 commit comments