1# CMake build for libtiff 2# 3# Copyright © 2015 Open Microscopy Environment / University of Dundee 4# Written by Roger Leigh <[email protected]> 5# 6# Permission to use, copy, modify, distribute, and sell this software and 7# its documentation for any purpose is hereby granted without fee, provided 8# that (i) the above copyright notices and this permission notice appear in 9# all copies of the software and related documentation, and (ii) the names of 10# Sam Leffler and Silicon Graphics may not be used in any advertising or 11# publicity relating to the software without the specific, prior written 12# permission of Sam Leffler and Silicon Graphics. 13# 14# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 15# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 16# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 17# 18# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 19# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 20# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 21# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 22# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 23# OF THIS SOFTWARE. 24 25include_directories(${PROJECT_SOURCE_DIR}/libtiff 26 ${PROJECT_BINARY_DIR}/libtiff 27 ${CMAKE_CURRENT_BINARY_DIR} 28 ${TIFF_INCLUDES}) 29 30# Test scripts (not used by CMake) 31set(TESTSCRIPTS 32 bmp2tiff_palette.sh 33 bmp2tiff_rgb.sh 34 gif2tiff.sh 35 ppm2tiff_pbm.sh 36 ppm2tiff_pgm.sh 37 ppm2tiff_ppm.sh 38 tiffcp-g3.sh 39 tiffcp-g3-1d.sh 40 tiffcp-g3-1d-fill.sh 41 tiffcp-g3-2d.sh 42 tiffcp-g3-2d-fill.sh 43 tiffcp-g4.sh 44 tiffcp-logluv.sh 45 tiffcp-thumbnail.sh 46 tiffdump.sh 47 tiffinfo.sh 48 tiffcp-split.sh 49 tiffcp-split-join.sh 50 tiff2ps-PS1.sh 51 tiff2ps-PS2.sh 52 tiff2ps-PS3.sh 53 tiff2ps-EPS1.sh 54 tiff2pdf.sh 55 tiffcrop-doubleflip-logluv-3c-16b.sh 56 tiffcrop-doubleflip-minisblack-1c-16b.sh 57 tiffcrop-doubleflip-minisblack-1c-8b.sh 58 tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh 59 tiffcrop-doubleflip-miniswhite-1c-1b.sh 60 tiffcrop-doubleflip-palette-1c-1b.sh 61 tiffcrop-doubleflip-palette-1c-4b.sh 62 tiffcrop-doubleflip-palette-1c-8b.sh 63 tiffcrop-doubleflip-rgb-3c-16b.sh 64 tiffcrop-doubleflip-rgb-3c-8b.sh 65 tiffcrop-extract-logluv-3c-16b.sh 66 tiffcrop-extract-minisblack-1c-16b.sh 67 tiffcrop-extract-minisblack-1c-8b.sh 68 tiffcrop-extract-minisblack-2c-8b-alpha.sh 69 tiffcrop-extract-miniswhite-1c-1b.sh 70 tiffcrop-extract-palette-1c-1b.sh 71 tiffcrop-extract-palette-1c-4b.sh 72 tiffcrop-extract-palette-1c-8b.sh 73 tiffcrop-extract-rgb-3c-16b.sh 74 tiffcrop-extract-rgb-3c-8b.sh 75 tiffcrop-extractz14-logluv-3c-16b.sh 76 tiffcrop-extractz14-minisblack-1c-16b.sh 77 tiffcrop-extractz14-minisblack-1c-8b.sh 78 tiffcrop-extractz14-minisblack-2c-8b-alpha.sh 79 tiffcrop-extractz14-miniswhite-1c-1b.sh 80 tiffcrop-extractz14-palette-1c-1b.sh 81 tiffcrop-extractz14-palette-1c-4b.sh 82 tiffcrop-extractz14-palette-1c-8b.sh 83 tiffcrop-extractz14-rgb-3c-16b.sh 84 tiffcrop-extractz14-rgb-3c-8b.sh 85 tiffcrop-R90-logluv-3c-16b.sh 86 tiffcrop-R90-minisblack-1c-16b.sh 87 tiffcrop-R90-minisblack-1c-8b.sh 88 tiffcrop-R90-minisblack-2c-8b-alpha.sh 89 tiffcrop-R90-miniswhite-1c-1b.sh 90 tiffcrop-R90-palette-1c-1b.sh 91 tiffcrop-R90-palette-1c-4b.sh 92 tiffcrop-R90-palette-1c-8b.sh 93 tiffcrop-R90-rgb-3c-16b.sh 94 tiffcrop-R90-rgb-3c-8b.sh 95 tiff2rgba-logluv-3c-16b.sh 96 tiff2rgba-minisblack-1c-16b.sh 97 tiff2rgba-minisblack-1c-8b.sh 98 tiff2rgba-minisblack-2c-8b-alpha.sh 99 tiff2rgba-miniswhite-1c-1b.sh 100 tiff2rgba-palette-1c-1b.sh 101 tiff2rgba-palette-1c-4b.sh 102 tiff2rgba-palette-1c-8b.sh 103 tiff2rgba-rgb-3c-16b.sh 104 tiff2rgba-rgb-3c-8b.sh 105 tiff2rgba-quad-tile.jpg.sh) 106 107# This list should contain all of the TIFF files in the 'images' 108# subdirectory which are intended to be used as input images for 109# tests. All of these files should use the extension ".tiff". 110set(TIFFIMAGES 111 images/logluv-3c-16b.tiff 112 images/minisblack-1c-16b.tiff 113 images/minisblack-1c-8b.tiff 114 images/minisblack-2c-8b-alpha.tiff 115 images/miniswhite-1c-1b.tiff 116 images/palette-1c-1b.tiff 117 images/palette-1c-4b.tiff 118 images/palette-1c-8b.tiff 119 images/rgb-3c-16b.tiff 120 images/rgb-3c-8b.tiff 121 images/quad-tile.jpg.tiff) 122 123set(BMPIMAGES 124 images/palette-1c-8b.bmp 125 images/rgb-3c-8b.bmp) 126 127set(GIFIMAGES 128 images/palette-1c-8b.gif) 129 130set(PNMIMAGES 131 images/minisblack-1c-8b.pgm 132 images/miniswhite-1c-1b.pbm 133 images/rgb-3c-8b.ppm) 134 135# All uncompressed image files 136set(UNCOMPRESSEDIMAGES 137 images/minisblack-1c-16b.tiff 138 images/minisblack-1c-8b.tiff 139 images/miniswhite-1c-1b.tiff 140 images/palette-1c-1b.tiff 141 images/palette-1c-4b.tiff 142 images/palette-1c-8b.tiff 143 images/rgb-3c-8b.tiff) 144 145# This list should include all of the files in the 'images' 146# subdirectory which are intended to be distributed. This may include 147# files which are not currently used by the tests. 148set(IMAGES_EXTRA_DIST 149 images/README.txt 150 ${BMPIMAGES} 151 ${GIFIMAGES} 152 ${PNMIMAGES} 153 ${TIFFIMAGES}) 154 155extra_dist( 156 ${TESTSCRIPTS} 157 ${IMAGES_EXTRA_DIST} 158 common.sh) 159 160set(noinst_HEADERS tifftest.h) 161 162add_executable(ascii_tag ascii_tag.c) 163target_link_libraries(ascii_tag tiff port) 164 165add_executable(long_tag long_tag.c check_tag.c) 166target_link_libraries(long_tag tiff port) 167 168add_executable(short_tag short_tag.c check_tag.c) 169target_link_libraries(short_tag tiff port) 170 171add_executable(strip_rw strip_rw.c strip.c test_arrays.c test_arrays.h) 172target_link_libraries(strip_rw tiff port) 173 174add_executable(rewrite rewrite_tag.c) 175target_link_libraries(rewrite tiff port) 176 177if(JPEG_SUPPORT) 178 add_executable(raw_decode raw_decode.c) 179 target_link_libraries(raw_decode tiff port) 180endif() 181 182add_executable(custom_dir custom_dir.c) 183target_link_libraries(custom_dir tiff port) 184 185set(TEST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output") 186file(MAKE_DIRECTORY "${TEST_OUTPUT}") 187 188macro(tiff_test_convert name command1 command2 command3 infile outfile validate) 189 add_test(NAME "${name}" 190 COMMAND "${CMAKE_COMMAND}" 191 "-DCONVERT_COMMAND1=${command1}" 192 "-DCONVERT_COMMAND2=${command2}" 193 "-DCONVERT_COMMAND3=${command3}" 194 "-DINFILE=${infile}" 195 "-DOUTFILE=${outfile}" 196 "-DTIFFINFO=$<TARGET_FILE:tiffinfo>" 197 "-DLIBTIFF=$<TARGET_FILE:tiff>" 198 "-DVALIDATE=${validate}" 199 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") 200endmacro() 201 202macro(tiff_test_stdout name command infile outfile) 203 add_test(NAME "${name}" 204 COMMAND "${CMAKE_COMMAND}" 205 "-DSTDOUT_COMMAND=${command}" 206 "-DINFILE=${infile}" 207 "-DOUTFILE=${outfile}" 208 "-DTIFFINFO=$<TARGET_FILE:tiffinfo>" 209 "-DLIBTIFF=$<TARGET_FILE:tiff>" 210 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") 211endmacro() 212 213macro(tiff_test_reader name command infile) 214 add_test(NAME "${name}" 215 COMMAND "${CMAKE_COMMAND}" 216 "-DREADER_COMMAND=${command}" 217 "-DINFILE=${infile}" 218 "-DTIFFINFO=$<TARGET_FILE:tiffinfo>" 219 "-DLIBTIFF=$<TARGET_FILE:tiff>" 220 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") 221endmacro() 222 223macro(add_convert_test_multi commandname1 commandname2 commandname3 224 categoryname commandargs1 commandargs2 commandargs3 225 image validate) 226 string(REPLACE " " "^" escaped_commandargs1 "${commandargs1}") 227 string(REPLACE " " "^" escaped_commandargs2 "${commandargs2}") 228 string(REPLACE " " "^" escaped_commandargs3 "${commandargs3}") 229 get_filename_component(name "${image}" NAME) 230 get_filename_component(base "${image}" NAME_WE) 231 set(testname "${commandname1}-${categoryname}-${base}") 232 if(commandname1) 233 set(command1 234 "$<TARGET_FILE:${commandname1}>^${escaped_commandargs1}") 235 else() 236 set(command1) 237 endif() 238 if(commandname2) 239 set(command2 240 "$<TARGET_FILE:${commandname2}>^${escaped_commandargs2}") 241 else() 242 set(command2) 243 endif() 244 if(commandname3) 245 set(command3 246 "$<TARGET_FILE:${commandname3}>^${escaped_commandargs3}") 247 else() 248 set(command3) 249 endif() 250 set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}") 251 set(outfile "${TEST_OUTPUT}/${commandname1}-${categoryname}-${name}") 252 string(REGEX REPLACE "\\.tiff\$" "" name "${name}") 253 tiff_test_convert("${testname}" "${command1}" "${command2}" "${command3}" 254 "${infile}" "${outfile}" "${validate}") 255endmacro() 256 257macro(add_convert_test commandname 258 categoryname commandargs 259 image validate) 260 add_convert_test_multi("${commandname}" "" "" 261 "${categoryname}" "${commandargs}" "" "" 262 "${image}" "${validate}") 263endmacro() 264 265macro(add_convert_tests_multi commandname commandname2 commandname3 266 categoryname 267 commandargs1 commandargs2 commandargs3 268 images validate) 269 foreach(file ${${images}}) 270 add_convert_test_multi("${commandname1}" "${commandname2}" 271 "${commandname3}" "${categoryname}" 272 "${commandargs1}" "${commandargs2}" 273 "${commandargs3}" "${file}" "${validate}") 274 endforeach() 275endmacro() 276 277macro(add_convert_tests commandname categoryname commandargs images validate) 278 foreach(file ${${images}}) 279 add_convert_test("${commandname}" "${categoryname}" 280 "${commandargs}" "${file}" "${validate}") 281 endforeach() 282endmacro() 283 284macro(add_stdout_test commandname commandargs image) 285 string(REPLACE " " "^" escaped_commandargs "${commandargs}") 286 get_filename_component(name "${image}" NAME) 287 get_filename_component(base "${image}" NAME_WE) 288 set(testname "${commandname}-${base}") 289 set(command "$<TARGET_FILE:${commandname}>^${escaped_commandargs}") 290 set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}") 291 set(outfile "${TEST_OUTPUT}/${commandname}-${name}") 292 string(REGEX REPLACE "\\.tiff\$" "" name "${name}") 293 tiff_test_stdout("${testname}" "${command}" "${infile}" "${outfile}") 294endmacro() 295 296macro(add_reader_test commandname commandargs image) 297 string(REPLACE " " "^" escaped_commandargs "${commandargs}") 298 get_filename_component(name "${image}" NAME) 299 get_filename_component(base "${image}" NAME_WE) 300 set(testname "${commandname}-${base}") 301 set(command "$<TARGET_FILE:${commandname}>^${escaped_commandargs}") 302 set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}") 303 string(REGEX REPLACE "\\.tiff\$" "" name "${name}") 304 tiff_test_reader("${testname}" "${command}" "${infile}") 305endmacro() 306 307# BMP 308add_convert_test(bmp2tiff palette "" "images/palette-1c-8b.bmp" TRUE) 309add_convert_test(bmp2tiff rgb "" "images/rgb-3c-8b.bmp" TRUE) 310 311# GIF 312add_convert_test(gif2tiff palette "" "images/palette-1c-8b.gif" TRUE) 313 314# PPM 315add_convert_test(ppm2tiff miniswhite "" "images/miniswhite-1c-1b.pbm" TRUE) 316add_convert_test(ppm2tiff minisblack "" "images/minisblack-1c-8b.pgm" TRUE) 317add_convert_test(ppm2tiff rgb "" "images/rgb-3c-8b.ppm" TRUE) 318 319# tiffcp 320add_convert_test(tiffcp g3 "-c g3" "images/miniswhite-1c-1b.tiff" FALSE) 321add_convert_test(tiffcp g31d "-c g3:1d" "images/miniswhite-1c-1b.tiff" FALSE) 322add_convert_test(tiffcp g31dfill "-c g3:1d:fill" "images/miniswhite-1c-1b.tiff" FALSE) 323add_convert_test(tiffcp g32d "-c g3:2d" "images/miniswhite-1c-1b.tiff" FALSE) 324add_convert_test(tiffcp g32dfill "-c g3:2d:fill" "images/miniswhite-1c-1b.tiff" FALSE) 325add_convert_test(tiffcp g4 "-c g4" "images/miniswhite-1c-1b.tiff" FALSE) 326add_convert_test_multi(tiffcp tiffcp "" logluv "-c none" "-c sgilog" "" 327 "images/logluv-3c-16b.tiff" FALSE) 328add_convert_test_multi(tiffcp thumbnail "" thumbnail "g3:1d" "" "" 329 "images/miniswhite-1c-1b.tiff" FALSE) 330 331# tiffdump 332add_reader_test(tiffdump "" "images/miniswhite-1c-1b.tiff") 333 334# tiffinfo 335add_reader_test(tiffinfo "-c -D -d -j -s" "images/minisblack-1c-16b.tiff") 336 337# tiffcp split/join 338foreach(image ${UNCOMPRESSEDIMAGES}) 339 list(APPEND ESCAPED_UNCOMPRESSED "${CMAKE_CURRENT_SOURCE_DIR}/${image}") 340endforeach() 341string(REPLACE ";" "^" ESCAPED_UNCOMPRESSED "${ESCAPED_UNCOMPRESSED}") 342add_test(NAME "tiffcp-split" 343 COMMAND "${CMAKE_COMMAND}" 344 "-DTESTFILES=${ESCAPED_UNCOMPRESSED}" 345 "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-conjoined.tif" 346 "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-split-" 347 "-DTIFFCP=$<TARGET_FILE:tiffcp>" 348 "-DTIFFSPLIT=$<TARGET_FILE:tiffsplit>" 349 "-DLIBTIFF=$<TARGET_FILE:tiff>" 350 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") 351add_test(NAME "tiffcp-split-join" 352 COMMAND "${CMAKE_COMMAND}" 353 "-DTESTFILES=${ESCAPED_UNCOMPRESSED}" 354 "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-join-conjoined.tif" 355 "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-join-split-" 356 "-DRECONJOINED=${TEST_OUTPUT}/tiffcp-split-join-reconjoined.tif" 357 "-DTIFFCP=$<TARGET_FILE:tiffcp>" 358 "-DTIFFSPLIT=$<TARGET_FILE:tiffsplit>" 359 "-DLIBTIFF=$<TARGET_FILE:tiff>" 360 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") 361 362# PDF 363add_stdout_test(tiff2pdf "" "images/miniswhite-1c-1b.tiff" TRUE) 364 365# RGBA 366add_convert_tests(tiff2rgba default "" TIFFIMAGES TRUE) 367# Test rotations 368add_convert_tests(tiffcrop R90 "-R90" TIFFIMAGES TRUE) 369# Test flip (mirror) 370add_convert_tests(tiffcrop doubleflip "-F both" TIFFIMAGES TRUE) 371# Test extracting a section 60 pixels wide and 60 pixels high 372add_convert_tests(tiffcrop extract "-U px -E top -X 60 -Y 60" TIFFIMAGES TRUE) 373# Test extracting the first and fourth quarters from the left side. 374add_convert_tests(tiffcrop extractz14 "-E left -Z1:4,2:4" TIFFIMAGES TRUE) 375