1 # CMake build for libtiff
3 # Copyright © 2015 Open Microscopy Environment / University of Dundee
4 # Written by Roger Leigh <rleigh@codelibre.net>
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.
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.
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
25 include_directories(${PROJECT_SOURCE_DIR}/libtiff
26 ${PROJECT_BINARY_DIR}/libtiff
27 ${CMAKE_CURRENT_BINARY_DIR}
30 # Test scripts (not used by CMake)
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)
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".
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)
124 images/palette-1c-8b.bmp
125 images/rgb-3c-8b.bmp)
128 images/palette-1c-8b.gif)
131 images/minisblack-1c-8b.pgm
132 images/miniswhite-1c-1b.pbm
133 images/rgb-3c-8b.ppm)
135 # All uncompressed image files
136 set(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)
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.
148 set(IMAGES_EXTRA_DIST
160 set(noinst_HEADERS tifftest.h)
162 add_executable(ascii_tag ascii_tag.c)
163 target_link_libraries(ascii_tag tiff port)
165 add_executable(long_tag long_tag.c check_tag.c)
166 target_link_libraries(long_tag tiff port)
168 add_executable(short_tag short_tag.c check_tag.c)
169 target_link_libraries(short_tag tiff port)
171 add_executable(strip_rw strip_rw.c strip.c test_arrays.c test_arrays.h)
172 target_link_libraries(strip_rw tiff port)
174 add_executable(rewrite rewrite_tag.c)
175 target_link_libraries(rewrite tiff port)
178 add_executable(raw_decode raw_decode.c)
179 target_link_libraries(raw_decode tiff port)
182 add_executable(custom_dir custom_dir.c)
183 target_link_libraries(custom_dir tiff port)
185 set(TEST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output")
186 file(MAKE_DIRECTORY "${TEST_OUTPUT}")
188 macro(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}"
195 "-DOUTFILE=${outfile}"
196 "-DTIFFINFO=$<TARGET_FILE:tiffinfo>"
197 "-DLIBTIFF=$<TARGET_FILE:tiff>"
198 "-DVALIDATE=${validate}"
199 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
202 macro(tiff_test_stdout name command infile outfile)
203 add_test(NAME "${name}"
204 COMMAND "${CMAKE_COMMAND}"
205 "-DSTDOUT_COMMAND=${command}"
207 "-DOUTFILE=${outfile}"
208 "-DTIFFINFO=$<TARGET_FILE:tiffinfo>"
209 "-DLIBTIFF=$<TARGET_FILE:tiff>"
210 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
213 macro(tiff_test_reader name command infile)
214 add_test(NAME "${name}"
215 COMMAND "${CMAKE_COMMAND}"
216 "-DREADER_COMMAND=${command}"
218 "-DTIFFINFO=$<TARGET_FILE:tiffinfo>"
219 "-DLIBTIFF=$<TARGET_FILE:tiff>"
220 -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
223 macro(add_convert_test_multi commandname1 commandname2 commandname3
224 categoryname commandargs1 commandargs2 commandargs3
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}")
234 "$<TARGET_FILE:${commandname1}>^${escaped_commandargs1}")
240 "$<TARGET_FILE:${commandname2}>^${escaped_commandargs2}")
246 "$<TARGET_FILE:${commandname3}>^${escaped_commandargs3}")
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}")
257 macro(add_convert_test commandname
258 categoryname commandargs
260 add_convert_test_multi("${commandname}" "" ""
261 "${categoryname}" "${commandargs}" "" ""
262 "${image}" "${validate}")
265 macro(add_convert_tests_multi commandname commandname2 commandname3
267 commandargs1 commandargs2 commandargs3
269 foreach(file ${${images}})
270 add_convert_test_multi("${commandname1}" "${commandname2}"
271 "${commandname3}" "${categoryname}"
272 "${commandargs1}" "${commandargs2}"
273 "${commandargs3}" "${file}" "${validate}")
277 macro(add_convert_tests commandname categoryname commandargs images validate)
278 foreach(file ${${images}})
279 add_convert_test("${commandname}" "${categoryname}"
280 "${commandargs}" "${file}" "${validate}")
284 macro(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}")
296 macro(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}")
308 add_convert_test(bmp2tiff palette "" "images/palette-1c-8b.bmp" TRUE)
309 add_convert_test(bmp2tiff rgb "" "images/rgb-3c-8b.bmp" TRUE)
312 add_convert_test(gif2tiff palette "" "images/palette-1c-8b.gif" TRUE)
315 add_convert_test(ppm2tiff miniswhite "" "images/miniswhite-1c-1b.pbm" TRUE)
316 add_convert_test(ppm2tiff minisblack "" "images/minisblack-1c-8b.pgm" TRUE)
317 add_convert_test(ppm2tiff rgb "" "images/rgb-3c-8b.ppm" TRUE)
320 add_convert_test(tiffcp g3 "-c g3" "images/miniswhite-1c-1b.tiff" FALSE)
321 add_convert_test(tiffcp g31d "-c g3:1d" "images/miniswhite-1c-1b.tiff" FALSE)
322 add_convert_test(tiffcp g31dfill "-c g3:1d:fill" "images/miniswhite-1c-1b.tiff" FALSE)
323 add_convert_test(tiffcp g32d "-c g3:2d" "images/miniswhite-1c-1b.tiff" FALSE)
324 add_convert_test(tiffcp g32dfill "-c g3:2d:fill" "images/miniswhite-1c-1b.tiff" FALSE)
325 add_convert_test(tiffcp g4 "-c g4" "images/miniswhite-1c-1b.tiff" FALSE)
326 add_convert_test_multi(tiffcp tiffcp "" logluv "-c none" "-c sgilog" ""
327 "images/logluv-3c-16b.tiff" FALSE)
328 add_convert_test_multi(tiffcp thumbnail "" thumbnail "g3:1d" "" ""
329 "images/miniswhite-1c-1b.tiff" FALSE)
332 add_reader_test(tiffdump "" "images/miniswhite-1c-1b.tiff")
335 add_reader_test(tiffinfo "-c -D -d -j -s" "images/minisblack-1c-16b.tiff")
338 foreach(image ${UNCOMPRESSEDIMAGES})
339 list(APPEND ESCAPED_UNCOMPRESSED "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
341 string(REPLACE ";" "^" ESCAPED_UNCOMPRESSED "${ESCAPED_UNCOMPRESSED}")
342 add_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")
351 add_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")
363 add_stdout_test(tiff2pdf "" "images/miniswhite-1c-1b.tiff" TRUE)
366 add_convert_tests(tiff2rgba default "" TIFFIMAGES TRUE)
368 add_convert_tests(tiffcrop R90 "-R90" TIFFIMAGES TRUE)
370 add_convert_tests(tiffcrop doubleflip "-F both" TIFFIMAGES TRUE)
371 # Test extracting a section 60 pixels wide and 60 pixels high
372 add_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.
374 add_convert_tests(tiffcrop extractz14 "-E left -Z1:4,2:4" TIFFIMAGES TRUE)