diff -r -u libjpeg-turbo-1.4.2/cdjpeg.c libjpeg-turbo-1.4.2.new/cdjpeg.c --- libjpeg-turbo-1.4.2/cdjpeg.c 2015-09-21 14:48:32.000000000 -0400 +++ libjpeg-turbo-1.4.2.new/cdjpeg.c 2016-02-20 22:40:57.973194439 -0500 @@ -14,9 +14,10 @@ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include /* to declare isupper(), tolower() */ #ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ +# include /* to declare setmode()'s parameter macros */ +# ifdef HAVE_IO_H +# include /* to declare setmode() */ +# endif #endif diff -r -u libjpeg-turbo-1.4.2/CMakeLists.txt libjpeg-turbo-1.4.2.new/CMakeLists.txt --- libjpeg-turbo-1.4.2/CMakeLists.txt 2016-02-20 22:54:11.404336104 -0500 +++ libjpeg-turbo-1.4.2.new/CMakeLists.txt 2016-02-20 23:15:04.482449981 -0500 @@ -288,13 +288,28 @@ endif() if(WITH_12BIT) - set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED -DUSE_SETMODE") + set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED") else() - set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE") + set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED") set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c) set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) endif() +include(CheckIncludeFiles) +check_include_files(io.h HAVE_IO_H) +if(HAVE_IO_H) + set(COMPILE_FLAGS "-DHAVE_IO_H ${COMPILE_FLAGS}") + set(SETMODE_HEADERS "fcntl.h;io.h") +else() + set(SETMODE_HEADERS "fcntl.h") +endif() + +include(CheckPrototypeDefinition) +check_prototype_definition(setmode "int setmode(int fd, int mode)" "0" ${SETMODE_HEADERS} HAVE_SETMODE) +if(HAVE_SETMODE) + set(COMPILE_FLAGS "-DUSE_SETMODE ${COMPILE_FLAGS}") +endif() + if(ENABLE_STATIC) add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c ${CJPEG_BMP_SOURCES}) @@ -308,7 +323,7 @@ add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c) target_link_libraries(jpegtran-static jpeg-static) - set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE") + set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) endif() add_executable(rdjpgcom rdjpgcom.c) @@ -825,8 +840,8 @@ if(ENABLE_STATIC) install(TARGETS turbojpeg-static ARCHIVE DESTINATION lib) if(NOT ENABLE_SHARED) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static.exe - DESTINATION bin RENAME tjbench.exe) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static${CMAKE_EXECUTABLE_SUFFIX} + DESTINATION bin RENAME tjbench${CMAKE_EXECUTABLE_SUFFIX}) endif() endif() install(FILES ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include) @@ -835,12 +850,12 @@ if(ENABLE_STATIC) install(TARGETS jpeg-static ARCHIVE DESTINATION lib) if(NOT ENABLE_SHARED) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static.exe - DESTINATION bin RENAME cjpeg.exe) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static.exe - DESTINATION bin RENAME djpeg.exe) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jpegtran-static.exe - DESTINATION bin RENAME jpegtran.exe) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static${CMAKE_EXECUTABLE_SUFFIX} + DESTINATION bin RENAME cjpeg${CMAKE_EXECUTABLE_SUFFIX}) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static${CMAKE_EXECUTABLE_SUFFIX} + DESTINATION bin RENAME djpeg${CMAKE_EXECUTABLE_SUFFIX}) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jpegtran-static${CMAKE_EXECUTABLE_SUFFIX} + DESTINATION bin RENAME jpegtran${CMAKE_EXECUTABLE_SUFFIX}) endif() endif() diff -r -u libjpeg-turbo-1.4.2/rdjpgcom.c libjpeg-turbo-1.4.2.new/rdjpgcom.c --- libjpeg-turbo-1.4.2/rdjpgcom.c 2015-09-21 14:48:32.000000000 -0400 +++ libjpeg-turbo-1.4.2.new/rdjpgcom.c 2016-02-20 22:41:41.153502798 -0500 @@ -22,9 +22,10 @@ #endif #include /* to declare isupper(), tolower() */ #ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ +# include /* to declare setmode()'s parameter macros */ +# ifdef HAVE_IO_H +# include /* to declare setmode() */ +# endif #endif #ifdef USE_CCOMMAND /* command-line reader for Macintosh */ diff -r -u libjpeg-turbo-1.4.2/wrjpgcom.c libjpeg-turbo-1.4.2.new/wrjpgcom.c --- libjpeg-turbo-1.4.2/wrjpgcom.c 2015-09-21 14:48:32.000000000 -0400 +++ libjpeg-turbo-1.4.2.new/wrjpgcom.c 2016-02-20 22:41:20.297353819 -0500 @@ -21,9 +21,10 @@ #endif #include /* to declare isupper(), tolower() */ #ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ +# include /* to declare setmode()'s parameter macros */ +# ifdef HAVE_IO_H +# include /* to declare setmode() */ +# endif #endif #ifdef USE_CCOMMAND /* command-line reader for Macintosh */