check_c_source_runs(
"
#include <stdlib.h>
#include <string.h>
#include <tiffio.h>
int main(int argc, char *argv[]) {
TIFF *tiff = TIFFOpen(\"${CMAKE_CURRENT_BINARY_DIR}/file.tiff\", \"w\");
if (tiff == NULL) {
return 1;
}
/*
* This check is not quite correct as some codecs may not support
* these parameters. For example, JBIG doesn't support RGBA.
*/
TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, 1);
TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, 1);
TIFFSetField(tiff, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4);
TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(tiff, TIFFTAG_COMPRESSION, COMPRESSION_${tiff_codec});
TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tiff, (uint32)-1));
unsigned char scan[4];
memset(scan, 255, sizeof(scan));
if (TIFFWriteScanline(tiff, scan, 0, 0) < 0) {
return 2;
}
TIFFClose(tiff);
return 0;
}
"
HAVE_TIFF_WRITE_${tiff_codec}
)