shun-iwasawa 82a8f5
cmake_minimum_required(VERSION 2.8.12)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(CMAKE_EXECUTABLE_SUFFIX)
shun-iwasawa 82a8f5
  set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
project(libjpeg-turbo C)
shun-iwasawa 82a8f5
set(VERSION 2.0.6)
shun-iwasawa 82a8f5
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
shun-iwasawa 82a8f5
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
shun-iwasawa 82a8f5
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
shun-iwasawa 82a8f5
list(GET VERSION_TRIPLET 2 VERSION_REVISION)
shun-iwasawa 82a8f5
function(pad_number NUMBER OUTPUT_LEN)
shun-iwasawa 82a8f5
  string(LENGTH "${${NUMBER}}" INPUT_LEN)
shun-iwasawa 82a8f5
  if(INPUT_LEN LESS OUTPUT_LEN)
shun-iwasawa 82a8f5
    math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1")
shun-iwasawa 82a8f5
    set(NUM ${${NUMBER}})
shun-iwasawa 82a8f5
    foreach(C RANGE ${ZEROES})
shun-iwasawa 82a8f5
      set(NUM "0${NUM}")
shun-iwasawa 82a8f5
    endforeach()
shun-iwasawa 82a8f5
    set(${NUMBER} ${NUM} PARENT_SCOPE)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endfunction()
shun-iwasawa 82a8f5
pad_number(VERSION_MINOR 3)
shun-iwasawa 82a8f5
pad_number(VERSION_REVISION 3)
shun-iwasawa 82a8f5
set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
string(TIMESTAMP DEFAULT_BUILD "%Y%m%d")
shun-iwasawa 82a8f5
set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# NOTE: On Windows, this does nothing except when using MinGW or Cygwin.
shun-iwasawa 82a8f5
# CMAKE_BUILD_TYPE has no meaning in Visual Studio, and it always defaults to
shun-iwasawa 82a8f5
# Debug when using NMake.
shun-iwasawa 82a8f5
if(NOT CMAKE_BUILD_TYPE)
shun-iwasawa 82a8f5
  set(CMAKE_BUILD_TYPE Release)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# Detect CPU type and whether we're building 64-bit or 32-bit code
shun-iwasawa 82a8f5
math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8")
shun-iwasawa 82a8f5
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC)
shun-iwasawa 82a8f5
if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR
shun-iwasawa 82a8f5
  CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR
shun-iwasawa 82a8f5
  CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR
shun-iwasawa 82a8f5
  CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR
shun-iwasawa 82a8f5
  CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32")
shun-iwasawa 82a8f5
  if(BITS EQUAL 64)
shun-iwasawa 82a8f5
    set(CPU_TYPE x86_64)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(CPU_TYPE i386)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE})
shun-iwasawa 82a8f5
    set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE})
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR
shun-iwasawa 82a8f5
  CMAKE_SYSTEM_PROCESSOR_LC MATCHES "arm*")
shun-iwasawa 82a8f5
  if(BITS EQUAL 64)
shun-iwasawa 82a8f5
    set(CPU_TYPE arm64)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(CPU_TYPE arm)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ppc*" OR
shun-iwasawa 82a8f5
  CMAKE_SYSTEM_PROCESSOR_LC MATCHES "powerpc*")
shun-iwasawa 82a8f5
  set(CPU_TYPE powerpc)
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
message(STATUS "${BITS}-bit build (${CPU_TYPE})")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
# INSTALL DIRECTORIES
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WIN32)
shun-iwasawa 82a8f5
  if(MSVC)
shun-iwasawa 82a8f5
    set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}-gcc")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  if(BITS EQUAL 64)
shun-iwasawa 82a8f5
    set(CMAKE_INSTALL_DEFAULT_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}64")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(CMAKE_INSTALL_DEFAULT_PREFIX /opt/${CMAKE_PROJECT_NAME})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
shun-iwasawa 82a8f5
  set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}" CACHE PATH
shun-iwasawa 82a8f5
    "Directory into which to install ${CMAKE_PROJECT_NAME} (default: ${CMAKE_INSTALL_DEFAULT_PREFIX})"
shun-iwasawa 82a8f5
    FORCE)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# When the prefix is /opt/${CMAKE_PROJECT_NAME}, we assume that an "official"
shun-iwasawa 82a8f5
# build is being created, and thus we install things into specific locations.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(CMAKE_INSTALL_PREFIX STREQUAL "${CMAKE_INSTALL_DEFAULT_PREFIX}")
shun-iwasawa 82a8f5
  set(CMAKE_INSTALL_DEFAULT_DATAROOTDIR "")
shun-iwasawa 82a8f5
  set(CMAKE_INSTALL_DEFAULT_DOCDIR "<cmake_install_datarootdir>/doc")</cmake_install_datarootdir>
shun-iwasawa 82a8f5
  set(CMAKE_INSTALL_DEFAULT_JAVADIR "<cmake_install_datarootdir>/classes")</cmake_install_datarootdir>
shun-iwasawa 82a8f5
  if(UNIX AND NOT APPLE)
shun-iwasawa 82a8f5
    if(BITS EQUAL 64)
shun-iwasawa 82a8f5
      set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib64")
shun-iwasawa 82a8f5
    else()
shun-iwasawa 82a8f5
      set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib32")
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
include(cmakescripts/GNUInstallDirs.cmake)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
macro(report_directory var)
shun-iwasawa 82a8f5
  if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
shun-iwasawa 82a8f5
    message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  mark_as_advanced(CLEAR CMAKE_INSTALL_${var})
shun-iwasawa 82a8f5
endmacro()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(DIRLIST "BINDIR;DATAROOTDIR;DOCDIR;INCLUDEDIR;LIBDIR")
shun-iwasawa 82a8f5
if(UNIX)
shun-iwasawa 82a8f5
  list(APPEND DIRLIST "MANDIR")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
foreach(dir ${DIRLIST})
shun-iwasawa 82a8f5
  report_directory(${dir})
shun-iwasawa 82a8f5
endforeach()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
# CONFIGURATION OPTIONS
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
macro(boolean_number var)
shun-iwasawa 82a8f5
  if(${var})
shun-iwasawa 82a8f5
    set(${var} 1)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(${var} 0)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endmacro()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
option(ENABLE_SHARED "Build shared libraries" TRUE)
shun-iwasawa 82a8f5
boolean_number(ENABLE_SHARED)
shun-iwasawa 82a8f5
option(ENABLE_STATIC "Build static libraries" TRUE)
shun-iwasawa 82a8f5
boolean_number(ENABLE_STATIC)
shun-iwasawa 82a8f5
option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE)
shun-iwasawa 82a8f5
boolean_number(REQUIRE_SIMD)
shun-iwasawa 82a8f5
option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE)
shun-iwasawa 82a8f5
boolean_number(WITH_12BIT)
shun-iwasawa 82a8f5
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE)
shun-iwasawa 82a8f5
boolean_number(WITH_ARITH_DEC)
shun-iwasawa 82a8f5
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE)
shun-iwasawa 82a8f5
boolean_number(WITH_ARITH_ENC)
shun-iwasawa 82a8f5
option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE)
shun-iwasawa 82a8f5
boolean_number(WITH_JAVA)
shun-iwasawa 82a8f5
option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
shun-iwasawa 82a8f5
boolean_number(WITH_JPEG7)
shun-iwasawa 82a8f5
option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
shun-iwasawa 82a8f5
boolean_number(WITH_JPEG8)
shun-iwasawa 82a8f5
option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE)
shun-iwasawa 82a8f5
boolean_number(WITH_MEM_SRCDST)
shun-iwasawa 82a8f5
option(WITH_SIMD "Include SIMD extensions, if available for this platform" TRUE)
shun-iwasawa 82a8f5
boolean_number(WITH_SIMD)
shun-iwasawa 82a8f5
option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" TRUE)
shun-iwasawa 82a8f5
boolean_number(WITH_TURBOJPEG)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
macro(report_option var desc)
shun-iwasawa 82a8f5
  if(${var})
shun-iwasawa 82a8f5
    message(STATUS "${desc} enabled (${var} = ${${var}})")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    message(STATUS "${desc} disabled (${var} = ${${var}})")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endmacro()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_JAVA)
shun-iwasawa 82a8f5
  set(ENABLE_SHARED 1)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# Explicitly setting CMAKE_POSITION_INDEPENDENT_CODE=FALSE disables PIC for all
shun-iwasawa 82a8f5
# targets, which will cause the shared library builds to fail.  Thus, if shared
shun-iwasawa 82a8f5
# libraries are enabled and CMAKE_POSITION_INDEPENDENT_CODE is explicitly set
shun-iwasawa 82a8f5
# to FALSE, we need to unset it, thus restoring the default behavior
shun-iwasawa 82a8f5
# (automatically using PIC for shared library targets.)
shun-iwasawa 82a8f5
if(DEFINED CMAKE_POSITION_INDEPENDENT_CODE AND
shun-iwasawa 82a8f5
  NOT CMAKE_POSITION_INDEPENDENT_CODE AND ENABLE_SHARED)
shun-iwasawa 82a8f5
  unset(CMAKE_POSITION_INDEPENDENT_CODE CACHE)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
report_option(ENABLE_SHARED "Shared libraries")
shun-iwasawa 82a8f5
report_option(ENABLE_STATIC "Static libraries")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(ENABLE_SHARED)
shun-iwasawa 82a8f5
  set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_JPEG8 OR WITH_JPEG7)
shun-iwasawa 82a8f5
  set(WITH_ARITH_ENC 1)
shun-iwasawa 82a8f5
  set(WITH_ARITH_DEC 1)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(WITH_JPEG8)
shun-iwasawa 82a8f5
  set(WITH_MEM_SRCDST 0)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_12BIT)
shun-iwasawa 82a8f5
  set(WITH_ARITH_DEC 0)
shun-iwasawa 82a8f5
  set(WITH_ARITH_ENC 0)
shun-iwasawa 82a8f5
  set(WITH_JAVA 0)
shun-iwasawa 82a8f5
  set(WITH_SIMD 0)
shun-iwasawa 82a8f5
  set(WITH_TURBOJPEG 0)
shun-iwasawa 82a8f5
  set(BITS_IN_JSAMPLE 12)
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(BITS_IN_JSAMPLE 8)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
report_option(WITH_12BIT "12-bit JPEG support")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_ARITH_DEC)
shun-iwasawa 82a8f5
  set(D_ARITH_CODING_SUPPORTED 1)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(NOT WITH_12BIT)
shun-iwasawa 82a8f5
  report_option(WITH_ARITH_DEC "Arithmetic decoding support")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_ARITH_ENC)
shun-iwasawa 82a8f5
  set(C_ARITH_CODING_SUPPORTED 1)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(NOT WITH_12BIT)
shun-iwasawa 82a8f5
  report_option(WITH_ARITH_ENC "Arithmetic encoding support")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(NOT WITH_12BIT)
shun-iwasawa 82a8f5
  report_option(WITH_TURBOJPEG "TurboJPEG API library")
shun-iwasawa 82a8f5
  report_option(WITH_JAVA "TurboJPEG Java wrapper")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_MEM_SRCDST)
shun-iwasawa 82a8f5
  set(MEM_SRCDST_SUPPORTED 1)
shun-iwasawa 82a8f5
  set(MEM_SRCDST_FUNCTIONS "global:  jpeg_mem_dest;  jpeg_mem_src;")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(NOT WITH_JPEG8)
shun-iwasawa 82a8f5
  report_option(WITH_MEM_SRCDST "In-memory source/destination managers")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(SO_AGE 2)
shun-iwasawa 82a8f5
if(WITH_MEM_SRCDST)
shun-iwasawa 82a8f5
  set(SO_AGE 3)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_JPEG8)
shun-iwasawa 82a8f5
  set(JPEG_LIB_VERSION 80)
shun-iwasawa 82a8f5
elseif(WITH_JPEG7)
shun-iwasawa 82a8f5
  set(JPEG_LIB_VERSION 70)
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(JPEG_LIB_VERSION 62)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
math(EXPR JPEG_LIB_VERSION_DIV10 "${JPEG_LIB_VERSION} / 10")
shun-iwasawa 82a8f5
math(EXPR JPEG_LIB_VERSION_MOD10 "${JPEG_LIB_VERSION} % 10")
shun-iwasawa 82a8f5
if(JPEG_LIB_VERSION STREQUAL "62")
shun-iwasawa 82a8f5
  set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION})
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION_DIV10})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(JPEG_LIB_VERSION STREQUAL "80")
shun-iwasawa 82a8f5
  set(DEFAULT_SO_MINOR_VERSION 2)
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(DEFAULT_SO_MINOR_VERSION 0)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# This causes SO_MAJOR_VERSION/SO_MINOR_VERSION to reset to defaults if
shun-iwasawa 82a8f5
# WITH_JPEG7 or WITH_JPEG8 has changed.
shun-iwasawa 82a8f5
if((DEFINED WITH_JPEG7_INT AND NOT WITH_JPEG7 EQUAL WITH_JPEG7_INT) OR
shun-iwasawa 82a8f5
  (DEFINED WITH_JPEG8_INT AND NOT WITH_JPEG8 EQUAL WITH_JPEG8_INT))
shun-iwasawa 82a8f5
  set(FORCE_SO_VERSION "FORCE")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
set(WITH_JPEG7_INT ${WITH_JPEG7} CACHE INTERNAL "")
shun-iwasawa 82a8f5
set(WITH_JPEG8_INT ${WITH_JPEG8} CACHE INTERNAL "")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(SO_MAJOR_VERSION ${DEFAULT_SO_MAJOR_VERSION} CACHE STRING
shun-iwasawa 82a8f5
  "Major version of the libjpeg API shared library (default: ${DEFAULT_SO_MAJOR_VERSION})"
shun-iwasawa 82a8f5
  ${FORCE_SO_VERSION})
shun-iwasawa 82a8f5
set(SO_MINOR_VERSION ${DEFAULT_SO_MINOR_VERSION} CACHE STRING
shun-iwasawa 82a8f5
  "Minor version of the libjpeg API shared library (default: ${DEFAULT_SO_MINOR_VERSION})"
shun-iwasawa 82a8f5
  ${FORCE_SO_VERSION})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(JPEG_LIB_VERSION_DECIMAL "${JPEG_LIB_VERSION_DIV10}.${JPEG_LIB_VERSION_MOD10}")
shun-iwasawa 82a8f5
message(STATUS "Emulating libjpeg API/ABI v${JPEG_LIB_VERSION_DECIMAL} (WITH_JPEG7 = ${WITH_JPEG7}, WITH_JPEG8 = ${WITH_JPEG8})")
shun-iwasawa 82a8f5
message(STATUS "libjpeg API shared library version = ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# Because the TurboJPEG API library uses versioned symbols and changes the
shun-iwasawa 82a8f5
# names of functions whenever they are modified in a backward-incompatible
shun-iwasawa 82a8f5
# manner, it is always backward-ABI-compatible with itself, so the major and
shun-iwasawa 82a8f5
# minor SO versions don't change.  However, we increase the middle number (the
shun-iwasawa 82a8f5
# SO "age") whenever functions are added to the API.
shun-iwasawa 82a8f5
set(TURBOJPEG_SO_MAJOR_VERSION 0)
shun-iwasawa 82a8f5
set(TURBOJPEG_SO_VERSION 0.2.0)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
# COMPILER SETTINGS
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(MSVC)
shun-iwasawa 82a8f5
  option(WITH_CRT_DLL
shun-iwasawa 82a8f5
    "Link all ${CMAKE_PROJECT_NAME} libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.)  The default is to use the C run-time DLL only with the libraries and executables that need it."
shun-iwasawa 82a8f5
    FALSE)
shun-iwasawa 82a8f5
  if(NOT WITH_CRT_DLL)
shun-iwasawa 82a8f5
    # Use the static C library for all build types
shun-iwasawa 82a8f5
    foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
shun-iwasawa 82a8f5
      CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
shun-iwasawa 82a8f5
      if(${var} MATCHES "/MD")
shun-iwasawa 82a8f5
        string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
shun-iwasawa 82a8f5
      endif()
shun-iwasawa 82a8f5
    endforeach()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /wd4996")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
shun-iwasawa 82a8f5
  # Use the maximum optimization level for release builds
shun-iwasawa 82a8f5
  foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
shun-iwasawa 82a8f5
    if(${var} MATCHES "-O2")
shun-iwasawa 82a8f5
      string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}")
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endforeach()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
shun-iwasawa 82a8f5
  if(CMAKE_C_COMPILER_ID MATCHES "SunPro")
shun-iwasawa 82a8f5
    # Use the maximum optimization level for release builds
shun-iwasawa 82a8f5
    foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
shun-iwasawa 82a8f5
      if(${var} MATCHES "-xO3")
shun-iwasawa 82a8f5
        string(REGEX REPLACE "-xO3" "-xO5" ${var} "${${var}}")
shun-iwasawa 82a8f5
      endif()
shun-iwasawa 82a8f5
      if(${var} MATCHES "-xO2")
shun-iwasawa 82a8f5
        string(REGEX REPLACE "-xO2" "-xO5" ${var} "${${var}}")
shun-iwasawa 82a8f5
      endif()
shun-iwasawa 82a8f5
    endforeach()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
shun-iwasawa 82a8f5
message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(EFFECTIVE_LD_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
shun-iwasawa 82a8f5
message(STATUS "Linker flags = ${EFFECTIVE_LD_FLAGS}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
include(CheckCSourceCompiles)
shun-iwasawa 82a8f5
include(CheckIncludeFiles)
shun-iwasawa 82a8f5
include(CheckTypeSize)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
check_type_size("size_t" SIZE_T)
shun-iwasawa 82a8f5
check_type_size("unsigned long" UNSIGNED_LONG)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(SIZE_T EQUAL UNSIGNED_LONG)
shun-iwasawa 82a8f5
  check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc;  return __builtin_ctzl(a); }"
shun-iwasawa 82a8f5
    HAVE_BUILTIN_CTZL)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(MSVC)
shun-iwasawa 82a8f5
  check_include_files("intrin.h" HAVE_INTRIN_H)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(UNIX)
shun-iwasawa 82a8f5
  # Check for headers
shun-iwasawa 82a8f5
  check_include_files(locale.h HAVE_LOCALE_H)
shun-iwasawa 82a8f5
  check_include_files(stddef.h HAVE_STDDEF_H)
shun-iwasawa 82a8f5
  check_include_files(stdlib.h HAVE_STDLIB_H)
shun-iwasawa 82a8f5
  check_include_files(sys/types.h NEED_SYS_TYPES_H)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Check for functions
shun-iwasawa 82a8f5
  include(CheckSymbolExists)
shun-iwasawa 82a8f5
  check_symbol_exists(memset string.h HAVE_MEMSET)
shun-iwasawa 82a8f5
  check_symbol_exists(memcpy string.h HAVE_MEMCPY)
shun-iwasawa 82a8f5
  if(NOT HAVE_MEMSET AND NOT HAVE_MEMCPY)
shun-iwasawa 82a8f5
    set(NEED_BSD_STRINGS 1)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Check for types
shun-iwasawa 82a8f5
  check_type_size("unsigned char" UNSIGNED_CHAR)
shun-iwasawa 82a8f5
  check_type_size("unsigned short" UNSIGNED_SHORT)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Check for compiler features
shun-iwasawa 82a8f5
  check_c_source_compiles("int main(void) { typedef struct undefined_structure *undef_struct_ptr;  undef_struct_ptr ptr = 0;  return ptr != 0; }"
shun-iwasawa 82a8f5
    INCOMPLETE_TYPES)
shun-iwasawa 82a8f5
  if(INCOMPLETE_TYPES)
shun-iwasawa 82a8f5
    message(STATUS "Compiler supports pointers to undefined structures.")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(INCOMPLETE_TYPES_BROKEN 1)
shun-iwasawa 82a8f5
    message(STATUS "Compiler does not support pointers to undefined structures.")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(CMAKE_CROSSCOMPILING)
shun-iwasawa 82a8f5
    set(RIGHT_SHIFT_IS_UNSIGNED 0)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    include(CheckCSourceRuns)
shun-iwasawa 82a8f5
    check_c_source_runs("
shun-iwasawa 82a8f5
      #include <stdio.h></stdio.h>
shun-iwasawa 82a8f5
      #include <stdlib.h></stdlib.h>
shun-iwasawa 82a8f5
      int is_shifting_signed (long arg) {
shun-iwasawa 82a8f5
        long res = arg >> 4;
shun-iwasawa 82a8f5
        if (res == -0x7F7E80CL)
shun-iwasawa 82a8f5
          return 1; /* right shift is signed */
shun-iwasawa 82a8f5
        /* see if unsigned-shift hack will fix it. */
shun-iwasawa 82a8f5
        /* we can't just test exact value since it depends on width of long... */
shun-iwasawa 82a8f5
        res |= (~0L) << (32-4);
shun-iwasawa 82a8f5
        if (res == -0x7F7E80CL)
shun-iwasawa 82a8f5
          return 0; /* right shift is unsigned */
shun-iwasawa 82a8f5
        printf(\"Right shift isn't acting as I expect it to.\\\\n\");
shun-iwasawa 82a8f5
        printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
shun-iwasawa 82a8f5
        return 0; /* try it with unsigned anyway */
shun-iwasawa 82a8f5
      }
shun-iwasawa 82a8f5
      int main (void) {
shun-iwasawa 82a8f5
        exit(is_shifting_signed(-0x7F7E80B1L));
shun-iwasawa 82a8f5
      }" RIGHT_SHIFT_IS_UNSIGNED)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(CMAKE_CROSSCOMPILING)
shun-iwasawa 82a8f5
    set(__CHAR_UNSIGNED__ 0)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    check_c_source_runs("int main(void) { return ((char) -1 < 0); }"
shun-iwasawa 82a8f5
      __CHAR_UNSIGNED__)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(MSVC)
shun-iwasawa 82a8f5
  set(INLINE_OPTIONS "__inline;inline")
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(INLINE_OPTIONS "__inline__;inline")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
option(FORCE_INLINE "Force function inlining" TRUE)
shun-iwasawa 82a8f5
boolean_number(FORCE_INLINE)
shun-iwasawa 82a8f5
if(FORCE_INLINE)
shun-iwasawa 82a8f5
  if(MSVC)
shun-iwasawa 82a8f5
    list(INSERT INLINE_OPTIONS 0 "__forceinline")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    list(INSERT INLINE_OPTIONS 0 "inline __attribute__((always_inline))")
shun-iwasawa 82a8f5
    list(INSERT INLINE_OPTIONS 0 "__inline__ __attribute__((always_inline))")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
foreach(inline ${INLINE_OPTIONS})
shun-iwasawa 82a8f5
  check_c_source_compiles("${inline} static int foo(void) { return 0; } int main(void) { return foo(); }"
shun-iwasawa 82a8f5
    INLINE_WORKS)
shun-iwasawa 82a8f5
  if(INLINE_WORKS)
shun-iwasawa 82a8f5
    set(INLINE ${inline})
shun-iwasawa 82a8f5
    break()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endforeach()
shun-iwasawa 82a8f5
if(NOT INLINE_WORKS)
shun-iwasawa 82a8f5
  message(FATAL_ERROR "Could not determine how to inline functions.")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_TURBOJPEG)
shun-iwasawa 82a8f5
  if(MSVC)
shun-iwasawa 82a8f5
    set(THREAD_LOCAL "__declspec(thread)")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(THREAD_LOCAL "__thread")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  check_c_source_compiles("${THREAD_LOCAL} int i;  int main(void) { i = 0;  return i; }" HAVE_THREAD_LOCAL)
shun-iwasawa 82a8f5
  if(HAVE_THREAD_LOCAL)
shun-iwasawa 82a8f5
    message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    message(WARNING "Thread-local storage is not available.  The TurboJPEG API library's global error handler will not be thread-safe.")
shun-iwasawa 82a8f5
    unset(THREAD_LOCAL)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(UNIX AND NOT APPLE)
shun-iwasawa 82a8f5
  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };")
shun-iwasawa 82a8f5
  set(CMAKE_REQUIRED_FLAGS
shun-iwasawa 82a8f5
    "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
shun-iwasawa 82a8f5
  check_c_source_compiles("int main(void) { return 0; }" HAVE_VERSION_SCRIPT)
shun-iwasawa 82a8f5
  set(CMAKE_REQUIRED_FLAGS)
shun-iwasawa 82a8f5
  file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
shun-iwasawa 82a8f5
  if(HAVE_VERSION_SCRIPT)
shun-iwasawa 82a8f5
    message(STATUS "Linker supports GNU-style version scripts")
shun-iwasawa 82a8f5
    set(MAPFLAG "-Wl,--version-script,")
shun-iwasawa 82a8f5
    set(TJMAPFLAG "-Wl,--version-script,")
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    message(STATUS "Linker does not support GNU-style version scripts")
shun-iwasawa 82a8f5
    if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
shun-iwasawa 82a8f5
      # The Solaris linker doesn't like our version script for the libjpeg API
shun-iwasawa 82a8f5
      # library, but the version script for the TurboJPEG API library should
shun-iwasawa 82a8f5
      # still work.
shun-iwasawa 82a8f5
      file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map
shun-iwasawa 82a8f5
        "VERS_1 { global: foo;  local: *; }; VERS_2 { global: foo2; } VERS_1;")
shun-iwasawa 82a8f5
      set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared")
shun-iwasawa 82a8f5
      check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }"
shun-iwasawa 82a8f5
        HAVE_MAPFILE)
shun-iwasawa 82a8f5
      set(CMAKE_REQUIRED_FLAGS)
shun-iwasawa 82a8f5
      file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
shun-iwasawa 82a8f5
      if(HAVE_MAPFILE)
shun-iwasawa 82a8f5
        message(STATUS "Linker supports mapfiles")
shun-iwasawa 82a8f5
        set(TJMAPFLAG "-Wl,-M,")
shun-iwasawa 82a8f5
      else()
shun-iwasawa 82a8f5
        message(STATUS "Linker does not support mapfiles")
shun-iwasawa 82a8f5
      endif()
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# Generate files
shun-iwasawa 82a8f5
if(WIN32)
shun-iwasawa 82a8f5
  configure_file(win/jconfig.h.in jconfig.h)
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  configure_file(jconfig.h.in jconfig.h)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
configure_file(jconfigint.h.in jconfigint.h)
shun-iwasawa 82a8f5
if(UNIX)
shun-iwasawa 82a8f5
  configure_file(libjpeg.map.in libjpeg.map)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# Include directories and compiler definitions
shun-iwasawa 82a8f5
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
# TARGETS
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(CMAKE_EXECUTABLE_SUFFIX_TMP)
shun-iwasawa 82a8f5
  set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX_TMP})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
shun-iwasawa 82a8f5
  jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c
shun-iwasawa 82a8f5
  jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c
shun-iwasawa 82a8f5
  jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c
shun-iwasawa 82a8f5
  jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c
shun-iwasawa 82a8f5
  jdtrans.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c
shun-iwasawa 82a8f5
  jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
shun-iwasawa 82a8f5
  set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_ARITH_ENC)
shun-iwasawa 82a8f5
  set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_ARITH_DEC)
shun-iwasawa 82a8f5
  set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_SIMD)
shun-iwasawa 82a8f5
  add_subdirectory(simd)
shun-iwasawa 82a8f5
elseif(NOT WITH_12BIT)
shun-iwasawa 82a8f5
  message(STATUS "SIMD extensions: None (WITH_SIMD = ${WITH_SIMD})")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(WITH_SIMD)
shun-iwasawa 82a8f5
  message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})")
shun-iwasawa 82a8f5
  if(MSVC_IDE OR XCODE)
shun-iwasawa 82a8f5
    set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  add_library(simd OBJECT jsimd_none.c)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_JAVA)
shun-iwasawa 82a8f5
  add_subdirectory(java)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(ENABLE_SHARED)
shun-iwasawa 82a8f5
  add_subdirectory(sharedlib)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(ENABLE_STATIC)
shun-iwasawa 82a8f5
  add_library(jpeg-static STATIC ${JPEG_SOURCES} $<target_objects:simd></target_objects:simd>
shun-iwasawa 82a8f5
    ${SIMD_OBJS})
shun-iwasawa 82a8f5
  if(NOT MSVC)
shun-iwasawa 82a8f5
    set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_TURBOJPEG)
shun-iwasawa 82a8f5
  if(ENABLE_SHARED)
shun-iwasawa 82a8f5
    set(TURBOJPEG_SOURCES ${JPEG_SOURCES} $<target_objects:simd> ${SIMD_OBJS}</target_objects:simd>
shun-iwasawa 82a8f5
      turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c rdppm.c
shun-iwasawa 82a8f5
      wrbmp.c wrppm.c)
shun-iwasawa 82a8f5
    set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile)
shun-iwasawa 82a8f5
    if(WITH_JAVA)
shun-iwasawa 82a8f5
      set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
shun-iwasawa 82a8f5
      include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
shun-iwasawa 82a8f5
      set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile.jni)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
    add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
shun-iwasawa 82a8f5
    set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS
shun-iwasawa 82a8f5
      "-DBMP_SUPPORTED -DPPM_SUPPORTED")
shun-iwasawa 82a8f5
    if(WIN32)
shun-iwasawa 82a8f5
      set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
    if(MINGW)
shun-iwasawa 82a8f5
      set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
    if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR
shun-iwasawa 82a8f5
                  CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4))
shun-iwasawa 82a8f5
      if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
shun-iwasawa 82a8f5
        set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
shun-iwasawa 82a8f5
      endif()
shun-iwasawa 82a8f5
      set_target_properties(turbojpeg PROPERTIES MACOSX_RPATH 1)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
    set_target_properties(turbojpeg PROPERTIES
shun-iwasawa 82a8f5
      SOVERSION ${TURBOJPEG_SO_MAJOR_VERSION} VERSION ${TURBOJPEG_SO_VERSION})
shun-iwasawa 82a8f5
    if(TJMAPFLAG)
shun-iwasawa 82a8f5
      set_target_properties(turbojpeg PROPERTIES
shun-iwasawa 82a8f5
        LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}")
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c)
shun-iwasawa 82a8f5
    target_link_libraries(tjunittest turbojpeg)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_executable(tjbench tjbench.c tjutil.c)
shun-iwasawa 82a8f5
    target_link_libraries(tjbench turbojpeg)
shun-iwasawa 82a8f5
    if(UNIX)
shun-iwasawa 82a8f5
      target_link_libraries(tjbench m)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_executable(tjexample tjexample.c)
shun-iwasawa 82a8f5
    target_link_libraries(tjexample turbojpeg)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(ENABLE_STATIC)
shun-iwasawa 82a8f5
    add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $<target_objects:simd></target_objects:simd>
shun-iwasawa 82a8f5
      ${SIMD_OBJS} turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c
shun-iwasawa 82a8f5
      rdppm.c wrbmp.c wrppm.c)
shun-iwasawa 82a8f5
    set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS
shun-iwasawa 82a8f5
      "-DBMP_SUPPORTED -DPPM_SUPPORTED")
shun-iwasawa 82a8f5
    if(NOT MSVC)
shun-iwasawa 82a8f5
      set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c
shun-iwasawa 82a8f5
      md5/md5hl.c)
shun-iwasawa 82a8f5
    target_link_libraries(tjunittest-static turbojpeg-static)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_executable(tjbench-static tjbench.c tjutil.c)
shun-iwasawa 82a8f5
    target_link_libraries(tjbench-static turbojpeg-static)
shun-iwasawa 82a8f5
    if(UNIX)
shun-iwasawa 82a8f5
      target_link_libraries(tjbench-static m)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WIN32)
shun-iwasawa 82a8f5
  set(USE_SETMODE "-DUSE_SETMODE")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(WITH_12BIT)
shun-iwasawa 82a8f5
  set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}")
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
shun-iwasawa 82a8f5
  set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
shun-iwasawa 82a8f5
  set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(ENABLE_STATIC)
shun-iwasawa 82a8f5
  add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
shun-iwasawa 82a8f5
    ${CJPEG_BMP_SOURCES})
shun-iwasawa 82a8f5
  set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
shun-iwasawa 82a8f5
  target_link_libraries(cjpeg-static jpeg-static)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
shun-iwasawa 82a8f5
    wrppm.c ${DJPEG_BMP_SOURCES})
shun-iwasawa 82a8f5
  set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
shun-iwasawa 82a8f5
  target_link_libraries(djpeg-static jpeg-static)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
shun-iwasawa 82a8f5
  target_link_libraries(jpegtran-static jpeg-static)
shun-iwasawa 82a8f5
  set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "${USE_SETMODE}")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
add_executable(rdjpgcom rdjpgcom.c)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
add_executable(wrjpgcom wrjpgcom.c)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
# TESTS
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
add_subdirectory(md5)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(MSVC_IDE OR XCODE)
shun-iwasawa 82a8f5
  set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(OBJDIR "")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
enable_testing()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_12BIT)
shun-iwasawa 82a8f5
  set(TESTORIG testorig12.jpg)
shun-iwasawa 82a8f5
  set(MD5_JPEG_RGB_ISLOW 9d7369207c520d37f2c1cbfcb82b2964)
shun-iwasawa 82a8f5
  set(MD5_JPEG_RGB_ISLOW2 a00bd20d8ae49684640ef7177d2e0b64)
shun-iwasawa 82a8f5
  set(MD5_PPM_RGB_ISLOW f3301d2219783b8b3d942b7239fa50c0)
shun-iwasawa 82a8f5
  set(MD5_JPEG_422_IFAST_OPT 7322e3bd2f127f7de4b40d4480ce60e4)
shun-iwasawa 82a8f5
  set(MD5_PPM_422_IFAST 79807fa552899e66a04708f533e16950)
shun-iwasawa 82a8f5
  set(MD5_PPM_422M_IFAST 07737bfe8a7c1c87aaa393a0098d16b0)
shun-iwasawa 82a8f5
  set(MD5_JPEG_420_IFAST_Q100_PROG 008ab68d6ddbba04a8f01deee4e0f9f8)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_Q100_IFAST 1b3730122709f53d007255e8dfd3305e)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_Q100_IFAST 980a1a3c5bf9510022869d30b7d26566)
shun-iwasawa 82a8f5
  set(MD5_JPEG_GRAY_ISLOW 235c90707b16e2e069f37c888b2636d9)
shun-iwasawa 82a8f5
  set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca)
shun-iwasawa 82a8f5
  set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d)
shun-iwasawa 82a8f5
  set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_SSE a8c17daf77b457725ec929e215b603f8)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_SSE 42876ab9e5c2f76a87d08db5fbd57956)
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT a8c17daf77b457725ec929e215b603f8)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_SSE})
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_FP_CONTRACT
shun-iwasawa 82a8f5
    ${MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT})
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_FP_CONTRACT ${MD5_PPM_3x2_FLOAT_SSE})
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_387 bc6dbbefac2872f6b9d6c4a0ae60c3c0)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_387 bcc5723c61560463ac60f772e742d092)
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_MSVC e27840755870fa849872e58aa0cd1400)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_MSVC 6c2880b83bb1aa41dfe330e7a9768690)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_IFAST_PROG 1396cc2b7185cfe943d408c9d305339e)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_IFAST 3975985ef6eeb0a2cdc58daa651ccc00)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_11_8 800a16f9f4dc9b293197bfe11be10a82)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_9_8 06b7a92a9bc69f4dc36ec40f1937d55c)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_7_8 3ec444a14a4ab4eab88ffc49c48eca43)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_3_4 3e726b7ea872445b19437d1c1d4f0d93)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_5_8 a8a771abdc94301d20ffac119b2caccd)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_1_2 b419124dd5568b085787234866102866)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_3_8 343d19015531b7bbe746124127244fa8)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_1_4 35fd59d866e44659edfa3c18db2a3edb)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_1_8 ccaed48ac0aedefda5d4abe4013f4ad7)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_ISLOW_SKIP15_31 86664cd9dc956536409e44e244d20a97)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 452a21656115a163029cfba5c04fa76a)
shun-iwasawa 82a8f5
  set(MD5_PPM_444_ISLOW_SKIP1_6 ef63901f71ef7a75cd78253fc0914f84)
shun-iwasawa 82a8f5
  set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 15b173fb5872d9575572fbcc1b05956f)
shun-iwasawa 82a8f5
  set(MD5_JPEG_CROP cdb35ff4b4519392690ea040c56ea99c)
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  set(TESTORIG testorig.jpg)
shun-iwasawa 82a8f5
  set(MD5_JPEG_RGB_ISLOW 1d44a406f61da743b5fd31c0a9abdca3)
shun-iwasawa 82a8f5
  set(MD5_JPEG_RGB_ISLOW2 31d121e57b6c2934c890a7fc7763bcd4)
shun-iwasawa 82a8f5
  set(MD5_PPM_RGB_ISLOW 00a257f5393fef8821f2b88ac7421291)
shun-iwasawa 82a8f5
  set(MD5_BMP_RGB_ISLOW_565 f07d2e75073e4bb10f6c6f4d36e2e3be)
shun-iwasawa 82a8f5
  set(MD5_BMP_RGB_ISLOW_565D 4cfa0928ef3e6bb626d7728c924cfda4)
shun-iwasawa 82a8f5
  set(MD5_JPEG_422_IFAST_OPT 2540287b79d913f91665e660303ab2c8)
shun-iwasawa 82a8f5
  set(MD5_PPM_422_IFAST 35bd6b3f833bad23de82acea847129fa)
shun-iwasawa 82a8f5
  set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
shun-iwasawa 82a8f5
  set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
shun-iwasawa 82a8f5
  set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
shun-iwasawa 82a8f5
  set(MD5_JPEG_420_IFAST_Q100_PROG e59bb462016a8d9a748c330a3474bb55)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
shun-iwasawa 82a8f5
  set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
shun-iwasawa 82a8f5
  set(MD5_PPM_GRAY_ISLOW 8d3596c56eace32f205deccc229aa5ed)
shun-iwasawa 82a8f5
  set(MD5_PPM_GRAY_ISLOW_RGB 116424ac07b79e5e801f00508eab48ec)
shun-iwasawa 82a8f5
  set(MD5_BMP_GRAY_ISLOW_565 12f78118e56a2f48b966f792fedf23cc)
shun-iwasawa 82a8f5
  set(MD5_BMP_GRAY_ISLOW_565D bdbbd616441a24354c98553df5dc82db)
shun-iwasawa 82a8f5
  set(MD5_JPEG_420S_IFAST_OPT 388708217ac46273ca33086b22827ed8)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_SSE 343e3f8caf8af5986ebaf0bdc13b5c71)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_SSE 1a75f36e5904d6fc3a85a43da9ad89bb)
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT 9bca803d2042bd1eb03819e2bf92b3e5)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_NO_FP_CONTRACT f6bfab038438ed8f5522fbd33595dcdc)
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_FP_CONTRACT
shun-iwasawa 82a8f5
    ${MD5_JPEG_3x2_FLOAT_PROG_NO_FP_CONTRACT})
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_FP_CONTRACT 0e917a34193ef976b679a6b069b1be26)
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_387 1657664a410e0822c924b54f6f65e6e9)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_387 cb0a1f027f3d2917c902b5640214e025)
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_FLOAT_PROG_MSVC 7999ce9cd0ee9b6c7043b7351ab7639d)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_FLOAT_MSVC 28cdc448a6b75e97892f0e0f8d4b21f3)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  set(MD5_JPEG_3x2_IFAST_PROG 1ee5d2c1a77f2da495f993c8c7cceca5)
shun-iwasawa 82a8f5
  set(MD5_PPM_3x2_IFAST fd283664b3b49127984af0a7f118fccd)
shun-iwasawa 82a8f5
  set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
shun-iwasawa 82a8f5
  set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
shun-iwasawa 82a8f5
  # Since v1.5.1, libjpeg-turbo uses the separate non-fancy upsampling and
shun-iwasawa 82a8f5
  # YCbCr -> RGB color conversion routines rather than merged upsampling/color
shun-iwasawa 82a8f5
  # conversion when fancy upsampling is disabled on platforms that have a SIMD
shun-iwasawa 82a8f5
  # implementation of YCbCr -> RGB color conversion but no SIMD implementation
shun-iwasawa 82a8f5
  # of merged upsampling/color conversion.  This was intended to improve the
shun-iwasawa 82a8f5
  # performance of the Arm Neon SIMD extensions, the only SIMD extensions for
shun-iwasawa 82a8f5
  # which those circumstances currently apply.  The separate non-fancy
shun-iwasawa 82a8f5
  # upsampling and color conversion routines usually produce bitwise-identical
shun-iwasawa 82a8f5
  # output to the merged upsampling/color conversion routines, but that is not
shun-iwasawa 82a8f5
  # the case when skipping scanlines starting at an odd-numbered scanline.  In
shun-iwasawa 82a8f5
  # libjpeg-turbo 2.0.5 and prior, doing that while using merged h2v2
shun-iwasawa 82a8f5
  # upsampling caused a segfault, so this test validates the fix for that
shun-iwasawa 82a8f5
  # segfault.  Unfortunately, however, the test also produces different bitwise
shun-iwasawa 82a8f5
  # output when using the Neon SIMD extensions, because of the aforementioned
shun-iwasawa 82a8f5
  # optimization.  The easiest workaround is to use the old test from
shun-iwasawa 82a8f5
  # libjpeg-turbo 2.0.5 and prior when using the Neon SIMD extensions.  The
shun-iwasawa 82a8f5
  # aforementioned segfault never would have occurred with the Neon SIMD
shun-iwasawa 82a8f5
  # extensions anyhow, since merged upsampling is disabled when using them.
shun-iwasawa 82a8f5
  if((CPU_TYPE STREQUAL "arm64" OR CPU_TYPE STREQUAL "arm") AND WITH_SIMD)
shun-iwasawa 82a8f5
    set(MD5_PPM_420M_IFAST_ARI 72b59a99bcf1de24c5b27d151bde2437)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(MD5_PPM_420M_IFAST_ARI 57251da28a35b46eecb7177d82d10e0e)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  set(MD5_JPEG_420_ISLOW 9a68f56bc76e466aa7e52f415d0f4a5f)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_2_1 9f9de8c0612f8d06869b960b05abf9c9)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_15_8 b6875bc070720b899566cc06459b63b7)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_13_8 bc3452573c8152f6ae552939ee19f82f)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_11_8 d8cc73c0aaacd4556569b59437ba00a5)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_9_8 d25e61bc7eac0002f5b393aa223747b6)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_7_8 ddb564b7c74a09494016d6cd7502a946)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_3_4 8ed8e68808c3fbc4ea764fc9d2968646)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_5_8 a3363274999da2366a024efae6d16c9b)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_1_2 e692a315cea26b988c8e8b29a5dbcd81)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_3_8 79eca9175652ced755155c90e785a996)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_1_4 79cd778f8bf1a117690052cacdd54eca)
shun-iwasawa 82a8f5
  set(MD5_PPM_420M_ISLOW_1_8 391b3d4aca640c8567d6f8745eb2142f)
shun-iwasawa 82a8f5
  set(MD5_BMP_420_ISLOW_256 4980185e3776e89bd931736e1cddeee6)
shun-iwasawa 82a8f5
  set(MD5_BMP_420_ISLOW_565 bf9d13e16c4923b92e1faa604d7922cb)
shun-iwasawa 82a8f5
  set(MD5_BMP_420_ISLOW_565D 6bde71526acc44bcff76f696df8638d2)
shun-iwasawa 82a8f5
  set(MD5_BMP_420M_ISLOW_565 8dc0185245353cfa32ad97027342216f)
shun-iwasawa 82a8f5
  set(MD5_BMP_420M_ISLOW_565D ce034037d212bc403330df6f915c161b)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_ISLOW_SKIP15_31 c4c65c1e43d7275cd50328a61e6534f0)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_ISLOW_ARI_SKIP16_139 087c6b123db16ac00cb88c5b590bb74a)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 26eb36ccc7d1f0cb80cdabb0ac8b5d99)
shun-iwasawa 82a8f5
  set(MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4 886c6775af22370257122f8b16207e6d)
shun-iwasawa 82a8f5
  set(MD5_PPM_444_ISLOW_SKIP1_6 5606f86874cf26b8fcee1117a0a436a6)
shun-iwasawa 82a8f5
  set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 db87dc7ce26bcdc7a6b56239ce2b9d6c)
shun-iwasawa 82a8f5
  set(MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0 cb57b32bd6d03e35432362f7bf184b6d)
shun-iwasawa 82a8f5
  set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_JAVA)
shun-iwasawa 82a8f5
  add_test(TJUnitTest
shun-iwasawa 82a8f5
    ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
shun-iwasawa 82a8f5
      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
shun-iwasawa 82a8f5
      TJUnitTest)
shun-iwasawa 82a8f5
  add_test(TJUnitTest-yuv
shun-iwasawa 82a8f5
    ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
shun-iwasawa 82a8f5
      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
shun-iwasawa 82a8f5
      TJUnitTest -yuv)
shun-iwasawa 82a8f5
  add_test(TJUnitTest-yuv-nopad
shun-iwasawa 82a8f5
    ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
shun-iwasawa 82a8f5
      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
shun-iwasawa 82a8f5
      TJUnitTest -yuv -noyuvpad)
shun-iwasawa 82a8f5
  add_test(TJUnitTest-bi
shun-iwasawa 82a8f5
    ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
shun-iwasawa 82a8f5
      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
shun-iwasawa 82a8f5
      TJUnitTest -bi)
shun-iwasawa 82a8f5
  add_test(TJUnitTest-bi-yuv
shun-iwasawa 82a8f5
    ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
shun-iwasawa 82a8f5
      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
shun-iwasawa 82a8f5
      TJUnitTest -bi -yuv)
shun-iwasawa 82a8f5
  add_test(TJUnitTest-bi-yuv-nopad
shun-iwasawa 82a8f5
    ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
shun-iwasawa 82a8f5
      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
shun-iwasawa 82a8f5
      TJUnitTest -bi -yuv -noyuvpad)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(TEST_LIBTYPES "")
shun-iwasawa 82a8f5
if(ENABLE_SHARED)
shun-iwasawa 82a8f5
  set(TEST_LIBTYPES ${TEST_LIBTYPES} shared)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
if(ENABLE_STATIC)
shun-iwasawa 82a8f5
  set(TEST_LIBTYPES ${TEST_LIBTYPES} static)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(TESTIMAGES ${CMAKE_CURRENT_SOURCE_DIR}/testimages)
shun-iwasawa 82a8f5
set(MD5CMP ${CMAKE_CURRENT_BINARY_DIR}/md5/md5cmp)
shun-iwasawa 82a8f5
if(CMAKE_CROSSCOMPILING)
shun-iwasawa 82a8f5
  file(RELATIVE_PATH TESTIMAGES ${CMAKE_CURRENT_BINARY_DIR} ${TESTIMAGES})
shun-iwasawa 82a8f5
  file(RELATIVE_PATH MD5CMP ${CMAKE_CURRENT_BINARY_DIR} ${MD5CMP})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# The output of the floating point DCT/IDCT algorithms differs depending on the
shun-iwasawa 82a8f5
# type of floating point math used, so the FLOATTEST CMake variable must be
shun-iwasawa 82a8f5
# set in order to tell the testing system which floating point results it
shun-iwasawa 82a8f5
# should expect:
shun-iwasawa 82a8f5
#
shun-iwasawa 82a8f5
# sse = validate against the expected results from the libjpeg-turbo SSE SIMD
shun-iwasawa 82a8f5
#       extensions
shun-iwasawa 82a8f5
# no-fp-contract = validate against the expected results from the C code when
shun-iwasawa 82a8f5
#                  floating point expression contraction is disabled (the
shun-iwasawa 82a8f5
#                  default with Clang, with GCC when building for platforms
shun-iwasawa 82a8f5
#                  that lack fused multiply-add [FMA] instructions, or when
shun-iwasawa 82a8f5
#                  passing -ffp-contract=off to the compiler)
shun-iwasawa 82a8f5
# fp-contract = validate against the expected results from the C code when
shun-iwasawa 82a8f5
#               floating point expression contraction is enabled (the default
shun-iwasawa 82a8f5
#               with GCC when building for platforms that have fused multiply-
shun-iwasawa 82a8f5
#               add [FMA] instructions or when passing -ffp-contract=fast to
shun-iwasawa 82a8f5
#               the compiler)
shun-iwasawa 82a8f5
# 387 = validate against the expected results from the C code when the 387 FPU
shun-iwasawa 82a8f5
#       is being used for floating point math (which is generally the default
shun-iwasawa 82a8f5
#       with x86 compilers)
shun-iwasawa 82a8f5
# msvc = validate against the expected results from the C code when compiled
shun-iwasawa 82a8f5
#        with a 32-bit version of Visual C++
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
shun-iwasawa 82a8f5
  if(WITH_SIMD)
shun-iwasawa 82a8f5
    set(DEFAULT_FLOATTEST sse)
shun-iwasawa 82a8f5
  elseif(CPU_TYPE STREQUAL "x86_64")
shun-iwasawa 82a8f5
    set(DEFAULT_FLOATTEST no-fp-contract)
shun-iwasawa 82a8f5
  elseif(CPU_TYPE STREQUAL "i386" AND MSVC)
shun-iwasawa 82a8f5
    set(DEFAULT_FLOATTEST msvc)
shun-iwasawa 82a8f5
  # else we can't really set an intelligent default for i386.  The appropriate
shun-iwasawa 82a8f5
  # value could be 387, no-fp-contract, or fp-contract, depending on the
shun-iwasawa 82a8f5
  # compiler and compiler options.  We leave it to the user to set FLOATTEST
shun-iwasawa 82a8f5
  # manually.
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
else()
shun-iwasawa 82a8f5
  if((CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64") AND
shun-iwasawa 82a8f5
    NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
shun-iwasawa 82a8f5
    set(DEFAULT_FLOATTEST fp-contract)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    set(DEFAULT_FLOATTEST no-fp-contract)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
# This causes FLOATTEST to reset to the default value if WITH_SIMD has
shun-iwasawa 82a8f5
# changed.
shun-iwasawa 82a8f5
if(DEFINED WITH_SIMD_INT AND NOT WITH_SIMD EQUAL WITH_SIMD_INT)
shun-iwasawa 82a8f5
  set(FORCE_FLOATTEST "FORCE")
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
set(WITH_SIMD_INT ${WITH_SIMD} CACHE INTERNAL "")
shun-iwasawa 82a8f5
set(FLOATTEST ${DEFAULT_FLOATTEST} CACHE STRING
shun-iwasawa 82a8f5
  "The type of floating point math used by the floating point DCT/IDCT algorithms.  This tells the testing system which numerical results it should expect from those tests.  [sse = libjpeg-turbo x86/x86-64 SIMD extensions, no-fp-contract = generic FPU with floating point expression contraction disabled, fp-contract = generic FPU with floating point expression contraction enabled, 387 = 387 FPU, msvc = 32-bit Visual Studio] (default = ${DEFAULT_FLOATTEST})"
shun-iwasawa 82a8f5
  ${FORCE_FLOATTEST})
shun-iwasawa 82a8f5
message(STATUS "FLOATTEST = ${FLOATTEST}")
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(FLOATTEST)
shun-iwasawa 82a8f5
  string(TOUPPER ${FLOATTEST} FLOATTEST_UC)
shun-iwasawa 82a8f5
  string(REGEX REPLACE "-" "_" FLOATTEST_UC ${FLOATTEST_UC})
shun-iwasawa 82a8f5
  string(TOLOWER ${FLOATTEST} FLOATTEST)
shun-iwasawa 82a8f5
  if(NOT FLOATTEST STREQUAL "sse" AND
shun-iwasawa 82a8f5
    NOT FLOATTEST STREQUAL "no-fp-contract" AND
shun-iwasawa 82a8f5
    NOT FLOATTEST STREQUAL "fp-contract" AND NOT FLOATTEST STREQUAL "387" AND
shun-iwasawa 82a8f5
    NOT FLOATTEST STREQUAL "msvc")
shun-iwasawa 82a8f5
    message(FATAL_ERROR "\"${FLOATTEST}\" is not a valid value for FLOATTEST.")
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
foreach(libtype ${TEST_LIBTYPES})
shun-iwasawa 82a8f5
  if(libtype STREQUAL "static")
shun-iwasawa 82a8f5
    set(suffix -static)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  if(WITH_TURBOJPEG)
shun-iwasawa 82a8f5
    add_test(tjunittest-${libtype}
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix})
shun-iwasawa 82a8f5
    add_test(tjunittest-${libtype}-alloc
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -alloc)
shun-iwasawa 82a8f5
    add_test(tjunittest-${libtype}-yuv
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv)
shun-iwasawa 82a8f5
    add_test(tjunittest-${libtype}-yuv-alloc
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -alloc)
shun-iwasawa 82a8f5
    add_test(tjunittest-${libtype}-yuv-nopad
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -noyuvpad)
shun-iwasawa 82a8f5
    add_test(tjunittest-${libtype}-bmp
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -bmp)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    set(MD5_PPM_GRAY_TILE 89d3ca21213d9d864b50b4e4e7de4ca6)
shun-iwasawa 82a8f5
    set(MD5_PPM_420_8x8_TILE 847fceab15c5b7b911cb986cf0f71de3)
shun-iwasawa 82a8f5
    set(MD5_PPM_420_16x16_TILE ca45552a93687e078f7137cc4126a7b0)
shun-iwasawa 82a8f5
    set(MD5_PPM_420_32x32_TILE d8676f1d6b68df358353bba9844f4a00)
shun-iwasawa 82a8f5
    set(MD5_PPM_420_64x64_TILE 4e4c1a3d7ea4bace4f868bcbe83b7050)
shun-iwasawa 82a8f5
    set(MD5_PPM_420_128x128_TILE f24c3429c52265832beab9df72a0ceae)
shun-iwasawa 82a8f5
    set(MD5_PPM_420M_8x8_TILE bc25320e1f4c31ce2e610e43e9fd173c)
shun-iwasawa 82a8f5
    set(MD5_PPM_420M_TILE 75ffdf14602258c5c189522af57fa605)
shun-iwasawa 82a8f5
    set(MD5_PPM_422_8x8_TILE d83dacd9fc73b0a6f10c09acad64eb1e)
shun-iwasawa 82a8f5
    set(MD5_PPM_422_16x16_TILE 35077fb610d72dd743b1eb0cbcfe10fb)
shun-iwasawa 82a8f5
    set(MD5_PPM_422_32x32_TILE e6902ed8a449ecc0f0d6f2bf945f65f7)
shun-iwasawa 82a8f5
    set(MD5_PPM_422_64x64_TILE 2b4502a8f316cedbde1da7bce3d2231e)
shun-iwasawa 82a8f5
    set(MD5_PPM_422_128x128_TILE f0b5617d578f5e13c8eee215d64d4877)
shun-iwasawa 82a8f5
    set(MD5_PPM_422M_8x8_TILE 828941d7f41cd6283abd6beffb7fd51d)
shun-iwasawa 82a8f5
    set(MD5_PPM_422M_TILE e877ae1324c4a280b95376f7f018172f)
shun-iwasawa 82a8f5
    set(MD5_PPM_444_TILE 7964e41e67cfb8d0a587c0aa4798f9c3)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # Test compressing from/decompressing to an arbitrary subregion of a larger
shun-iwasawa 82a8f5
    # image buffer
shun-iwasawa 82a8f5
    add_test(tjbench-${libtype}-tile-cp
shun-iwasawa 82a8f5
      ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
        testout_tile.ppm)
shun-iwasawa 82a8f5
    add_test(tjbench-${libtype}-tile
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} testout_tile.ppm 95
shun-iwasawa 82a8f5
        -rgb -quiet -tile -benchtime 0.01 -warmup 0)
shun-iwasawa 82a8f5
    set_tests_properties(tjbench-${libtype}-tile
shun-iwasawa 82a8f5
      PROPERTIES DEPENDS tjbench-${libtype}-tile-cp)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    foreach(tile 8 16 32 64 128)
shun-iwasawa 82a8f5
      add_test(tjbench-${libtype}-tile-gray-${tile}x${tile}-cmp
shun-iwasawa 82a8f5
        ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_GRAY_TILE}
shun-iwasawa 82a8f5
          testout_tile_GRAY_Q95_${tile}x${tile}.ppm)
shun-iwasawa 82a8f5
      foreach(subsamp 420 422)
shun-iwasawa 82a8f5
        add_test(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
shun-iwasawa 82a8f5
          ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
shun-iwasawa 82a8f5
            ${MD5_PPM_${subsamp}_${tile}x${tile}_TILE}
shun-iwasawa 82a8f5
            testout_tile_${subsamp}_Q95_${tile}x${tile}.ppm)
shun-iwasawa 82a8f5
      endforeach()
shun-iwasawa 82a8f5
      add_test(tjbench-${libtype}-tile-444-${tile}x${tile}-cmp
shun-iwasawa 82a8f5
        ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_444_TILE}
shun-iwasawa 82a8f5
          testout_tile_444_Q95_${tile}x${tile}.ppm)
shun-iwasawa 82a8f5
      foreach(subsamp gray 420 422 444)
shun-iwasawa 82a8f5
        set_tests_properties(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
shun-iwasawa 82a8f5
          PROPERTIES DEPENDS tjbench-${libtype}-tile)
shun-iwasawa 82a8f5
      endforeach()
shun-iwasawa 82a8f5
    endforeach()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_test(tjbench-${libtype}-tilem-cp
shun-iwasawa 82a8f5
      ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
        testout_tilem.ppm)
shun-iwasawa 82a8f5
    add_test(tjbench-${libtype}-tilem
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} testout_tilem.ppm 95
shun-iwasawa 82a8f5
        -rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0)
shun-iwasawa 82a8f5
    set_tests_properties(tjbench-${libtype}-tilem
shun-iwasawa 82a8f5
      PROPERTIES DEPENDS tjbench-${libtype}-tilem-cp)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_test(tjbench-${libtype}-tile-420m-8x8-cmp
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_420M_8x8_TILE}
shun-iwasawa 82a8f5
        testout_tilem_420_Q95_8x8.ppm)
shun-iwasawa 82a8f5
    add_test(tjbench-${libtype}-tile-422m-8x8-cmp
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_422M_8x8_TILE}
shun-iwasawa 82a8f5
        testout_tilem_422_Q95_8x8.ppm)
shun-iwasawa 82a8f5
    foreach(tile 16 32 64 128)
shun-iwasawa 82a8f5
      foreach(subsamp 420 422)
shun-iwasawa 82a8f5
        add_test(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
shun-iwasawa 82a8f5
          ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
shun-iwasawa 82a8f5
            ${MD5_PPM_${subsamp}M_TILE}
shun-iwasawa 82a8f5
            testout_tilem_${subsamp}_Q95_${tile}x${tile}.ppm)
shun-iwasawa 82a8f5
      endforeach()
shun-iwasawa 82a8f5
    endforeach()
shun-iwasawa 82a8f5
    foreach(tile 8 16 32 64 128)
shun-iwasawa 82a8f5
      foreach(subsamp 420 422)
shun-iwasawa 82a8f5
        set_tests_properties(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
shun-iwasawa 82a8f5
          PROPERTIES DEPENDS tjbench-${libtype}-tilem)
shun-iwasawa 82a8f5
      endforeach()
shun-iwasawa 82a8f5
    endforeach()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # These tests are carefully crafted to provide full coverage of as many of
shun-iwasawa 82a8f5
  # the underlying algorithms as possible (including all of the
shun-iwasawa 82a8f5
  # SIMD-accelerated ones.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  macro(add_bittest PROG NAME ARGS OUTFILE INFILE MD5SUM)
shun-iwasawa 82a8f5
    add_test(${PROG}-${libtype}-${NAME}
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} ${PROG}${suffix} ${ARGS}
shun-iwasawa 82a8f5
        -outfile ${OUTFILE} ${INFILE})
shun-iwasawa 82a8f5
    add_test(${PROG}-${libtype}-${NAME}-cmp
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5SUM} ${OUTFILE})
shun-iwasawa 82a8f5
    set_tests_properties(${PROG}-${libtype}-${NAME}-cmp PROPERTIES
shun-iwasawa 82a8f5
      DEPENDS ${PROG}-${libtype}-${NAME})
shun-iwasawa 82a8f5
    if(${ARGC} GREATER 6)
shun-iwasawa 82a8f5
      set(DEPENDS ${ARGN})
shun-iwasawa 82a8f5
      set_tests_properties(${PROG}-${libtype}-${NAME} PROPERTIES
shun-iwasawa 82a8f5
        DEPENDS ${DEPENDS})
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endmacro()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: null  SAMP: fullsize  FDCT: islow  ENT: huff
shun-iwasawa 82a8f5
  add_bittest(cjpeg rgb-islow "-rgb;-dct;int;-icc;${TESTIMAGES}/test1.icc"
shun-iwasawa 82a8f5
    testout_rgb_islow.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
    ${MD5_JPEG_RGB_ISLOW})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: null  SAMP: fullsize  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
  add_bittest(djpeg rgb-islow "-dct;int;-ppm;-icc;testout_rgb_islow.icc"
shun-iwasawa 82a8f5
    testout_rgb_islow.ppm testout_rgb_islow.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_RGB_ISLOW} cjpeg-${libtype}-rgb-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  add_test(djpeg-${libtype}-rgb-islow-icc-cmp
shun-iwasawa 82a8f5
    ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
shun-iwasawa 82a8f5
      b06a39d730129122e85c1363ed1bbc9e testout_rgb_islow.icc)
shun-iwasawa 82a8f5
  set_tests_properties(djpeg-${libtype}-rgb-islow-icc-cmp PROPERTIES
shun-iwasawa 82a8f5
    DEPENDS djpeg-${libtype}-rgb-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  add_bittest(jpegtran icc "-copy;all;-icc;${TESTIMAGES}/test2.icc"
shun-iwasawa 82a8f5
    testout_rgb_islow2.jpg testout_rgb_islow.jpg
shun-iwasawa 82a8f5
    ${MD5_JPEG_RGB_ISLOW2} cjpeg-${libtype}-rgb-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(NOT WITH_12BIT)
shun-iwasawa 82a8f5
    # CC: RGB->RGB565  SAMP: fullsize  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg rgb-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
shun-iwasawa 82a8f5
      testout_rgb_islow_565.bmp testout_rgb_islow.jpg
shun-iwasawa 82a8f5
      ${MD5_BMP_RGB_ISLOW_565} cjpeg-${libtype}-rgb-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: RGB->RGB565 (dithered)  SAMP: fullsize  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg rgb-islow-565D "-dct;int;-rgb565;-bmp"
shun-iwasawa 82a8f5
      testout_rgb_islow_565D.bmp testout_rgb_islow.jpg
shun-iwasawa 82a8f5
      ${MD5_BMP_RGB_ISLOW_565D} cjpeg-${libtype}-rgb-islow)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: RGB->YCC  SAMP: fullsize/h2v1  FDCT: ifast  ENT: 2-pass huff
shun-iwasawa 82a8f5
  add_bittest(cjpeg 422-ifast-opt "-sample;2x1;-dct;fast;-opt"
shun-iwasawa 82a8f5
    testout_422_ifast_opt.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
    ${MD5_JPEG_422_IFAST_OPT})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: YCC->RGB  SAMP: fullsize/h2v1 fancy  IDCT: ifast  ENT: huff
shun-iwasawa 82a8f5
  add_bittest(djpeg 422-ifast "-dct;fast"
shun-iwasawa 82a8f5
    testout_422_ifast.ppm testout_422_ifast_opt.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_422_IFAST} cjpeg-${libtype}-422-ifast-opt)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: YCC->RGB  SAMP: h2v1 merged  IDCT: ifast  ENT: huff
shun-iwasawa 82a8f5
  add_bittest(djpeg 422m-ifast "-dct;fast;-nosmooth"
shun-iwasawa 82a8f5
    testout_422m_ifast.ppm testout_422_ifast_opt.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_422M_IFAST} cjpeg-${libtype}-422-ifast-opt)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(NOT WITH_12BIT)
shun-iwasawa 82a8f5
    # CC: YCC->RGB565  SAMP: h2v1 merged  IDCT: ifast  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 422m-ifast-565
shun-iwasawa 82a8f5
      "-dct;int;-nosmooth;-rgb565;-dither;none;-bmp"
shun-iwasawa 82a8f5
      testout_422m_ifast_565.bmp testout_422_ifast_opt.jpg
shun-iwasawa 82a8f5
      ${MD5_BMP_422M_IFAST_565} cjpeg-${libtype}-422-ifast-opt)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: YCC->RGB565 (dithered)  SAMP: h2v1 merged  IDCT: ifast  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 422m-ifast-565D "-dct;int;-nosmooth;-rgb565;-bmp"
shun-iwasawa 82a8f5
      testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg
shun-iwasawa 82a8f5
      ${MD5_BMP_422M_IFAST_565D} cjpeg-${libtype}-422-ifast-opt)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: RGB->YCC  SAMP: fullsize/h2v2  FDCT: ifast  ENT: prog huff
shun-iwasawa 82a8f5
  add_bittest(cjpeg 420-q100-ifast-prog
shun-iwasawa 82a8f5
    "-sample;2x2;-quality;100;-dct;fast;-scans;${TESTIMAGES}/test.scan"
shun-iwasawa 82a8f5
    testout_420_q100_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
    ${MD5_JPEG_420_IFAST_Q100_PROG})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: YCC->RGB  SAMP: fullsize/h2v2 fancy  IDCT: ifast  ENT: prog huff
shun-iwasawa 82a8f5
  add_bittest(djpeg 420-q100-ifast-prog "-dct;fast"
shun-iwasawa 82a8f5
    testout_420_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_420_Q100_IFAST} cjpeg-${libtype}-420-q100-ifast-prog)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: YCC->RGB  SAMP: h2v2 merged  IDCT: ifast  ENT: prog huff
shun-iwasawa 82a8f5
  add_bittest(djpeg 420m-q100-ifast-prog "-dct;fast;-nosmooth"
shun-iwasawa 82a8f5
    testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_420M_Q100_IFAST} cjpeg-${libtype}-420-q100-ifast-prog)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: RGB->Gray  SAMP: fullsize  FDCT: islow  ENT: huff
shun-iwasawa 82a8f5
  add_bittest(cjpeg gray-islow "-gray;-dct;int"
shun-iwasawa 82a8f5
    testout_gray_islow.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
    ${MD5_JPEG_GRAY_ISLOW})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: Gray->Gray  SAMP: fullsize  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
  add_bittest(djpeg gray-islow "-dct;int"
shun-iwasawa 82a8f5
    testout_gray_islow.ppm testout_gray_islow.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_GRAY_ISLOW} cjpeg-${libtype}-gray-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: Gray->RGB  SAMP: fullsize  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
  add_bittest(djpeg gray-islow-rgb "-dct;int;-rgb"
shun-iwasawa 82a8f5
    testout_gray_islow_rgb.ppm testout_gray_islow.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_GRAY_ISLOW_RGB} cjpeg-${libtype}-gray-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(NOT WITH_12BIT)
shun-iwasawa 82a8f5
    # CC: Gray->RGB565  SAMP: fullsize  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg gray-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
shun-iwasawa 82a8f5
      testout_gray_islow_565.bmp testout_gray_islow.jpg
shun-iwasawa 82a8f5
      ${MD5_BMP_GRAY_ISLOW_565} cjpeg-${libtype}-gray-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: Gray->RGB565 (dithered)  SAMP: fullsize  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg gray-islow-565D "-dct;int;-rgb565;-bmp"
shun-iwasawa 82a8f5
      testout_gray_islow_565D.bmp testout_gray_islow.jpg
shun-iwasawa 82a8f5
      ${MD5_BMP_GRAY_ISLOW_565D} cjpeg-${libtype}-gray-islow)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: RGB->YCC  SAMP: fullsize smooth/h2v2 smooth  FDCT: islow
shun-iwasawa 82a8f5
  # ENT: 2-pass huff
shun-iwasawa 82a8f5
  add_bittest(cjpeg 420s-ifast-opt "-sample;2x2;-smooth;1;-dct;int;-opt"
shun-iwasawa 82a8f5
    testout_420s_ifast_opt.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
    ${MD5_JPEG_420S_IFAST_OPT})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(FLOATTEST)
shun-iwasawa 82a8f5
    # CC: RGB->YCC  SAMP: fullsize/int  FDCT: float  ENT: prog huff
shun-iwasawa 82a8f5
    add_bittest(cjpeg 3x2-float-prog "-sample;3x2;-dct;float;-prog"
shun-iwasawa 82a8f5
      testout_3x2_float_prog.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
      ${MD5_JPEG_3x2_FLOAT_PROG_${FLOATTEST_UC}})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: YCC->RGB  SAMP: fullsize/int  IDCT: float  ENT: prog huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 3x2-float-prog "-dct;float"
shun-iwasawa 82a8f5
      testout_3x2_float.ppm testout_3x2_float_prog.jpg
shun-iwasawa 82a8f5
      ${MD5_PPM_3x2_FLOAT_${FLOATTEST_UC}} cjpeg-${libtype}-3x2-float-prog)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: RGB->YCC  SAMP: fullsize/int  FDCT: ifast  ENT: prog huff
shun-iwasawa 82a8f5
  add_bittest(cjpeg 3x2-ifast-prog "-sample;3x2;-dct;fast;-prog"
shun-iwasawa 82a8f5
    testout_3x2_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
    ${MD5_JPEG_3x2_IFAST_PROG})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # CC: YCC->RGB  SAMP: fullsize/int  IDCT: ifast  ENT: prog huff
shun-iwasawa 82a8f5
  add_bittest(djpeg 3x2-ifast-prog "-dct;fast"
shun-iwasawa 82a8f5
    testout_3x2_ifast.ppm testout_3x2_ifast_prog.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_3x2_IFAST} cjpeg-${libtype}-3x2-ifast-prog)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(WITH_ARITH_ENC)
shun-iwasawa 82a8f5
    # CC: YCC->RGB  SAMP: fullsize/h2v2  FDCT: islow  ENT: arith
shun-iwasawa 82a8f5
    add_bittest(cjpeg 420-islow-ari "-dct;int;-arithmetic"
shun-iwasawa 82a8f5
      testout_420_islow_ari.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
      ${MD5_JPEG_420_ISLOW_ARI})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_bittest(jpegtran 420-islow-ari "-arithmetic"
shun-iwasawa 82a8f5
      testout_420_islow_ari2.jpg ${TESTIMAGES}/testimgint.jpg
shun-iwasawa 82a8f5
      ${MD5_JPEG_420_ISLOW_ARI})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: YCC->RGB  SAMP: fullsize  FDCT: islow  ENT: prog arith
shun-iwasawa 82a8f5
    add_bittest(cjpeg 444-islow-progari
shun-iwasawa 82a8f5
      "-sample;1x1;-dct;int;-prog;-arithmetic"
shun-iwasawa 82a8f5
      testout_444_islow_progari.jpg ${TESTIMAGES}/testorig.ppm
shun-iwasawa 82a8f5
      ${MD5_JPEG_444_ISLOW_PROGARI})
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(WITH_ARITH_DEC)
shun-iwasawa 82a8f5
    # CC: RGB->YCC  SAMP: h2v2 merged  IDCT: ifast  ENT: arith
shun-iwasawa 82a8f5
    if((CPU_TYPE STREQUAL "arm64" OR CPU_TYPE STREQUAL "arm") AND WITH_SIMD)
shun-iwasawa 82a8f5
      # Refer to the comment above the definition of MD5_PPM_420M_IFAST_ARI for
shun-iwasawa 82a8f5
      # an explanation of why this is necessary.
shun-iwasawa 82a8f5
      add_bittest(djpeg 420m-ifast-ari "-fast;-ppm"
shun-iwasawa 82a8f5
        testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg
shun-iwasawa 82a8f5
        ${MD5_PPM_420M_IFAST_ARI})
shun-iwasawa 82a8f5
    else()
shun-iwasawa 82a8f5
      add_bittest(djpeg 420m-ifast-ari "-fast;-skip;1,20;-ppm"
shun-iwasawa 82a8f5
        testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg
shun-iwasawa 82a8f5
        ${MD5_PPM_420M_IFAST_ARI})
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    add_bittest(jpegtran 420-islow ""
shun-iwasawa 82a8f5
      testout_420_islow.jpg ${TESTIMAGES}/testimgari.jpg
shun-iwasawa 82a8f5
      ${MD5_JPEG_420_ISLOW})
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # 2/1--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 16x16 islow  ENT: huff
shun-iwasawa 82a8f5
  # 15/8--  CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 15x15 islow  ENT: huff
shun-iwasawa 82a8f5
  # 13/8--  CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 13x13 islow  ENT: huff
shun-iwasawa 82a8f5
  # 11/8--  CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 11x11 islow  ENT: huff
shun-iwasawa 82a8f5
  # 9/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 9x9 islow  ENT: huff
shun-iwasawa 82a8f5
  # 7/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 7x7 islow/14x14 islow
shun-iwasawa 82a8f5
  #         ENT: huff
shun-iwasawa 82a8f5
  # 3/4--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 6x6 islow/12x12 islow
shun-iwasawa 82a8f5
  #         ENT: huff
shun-iwasawa 82a8f5
  # 5/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 5x5 islow/10x10 islow
shun-iwasawa 82a8f5
  #         ENT: huff
shun-iwasawa 82a8f5
  # 1/2--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 4x4 islow/8x8 islow
shun-iwasawa 82a8f5
  #         ENT: huff
shun-iwasawa 82a8f5
  # 3/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 3x3 islow/6x6 islow
shun-iwasawa 82a8f5
  #         ENT: huff
shun-iwasawa 82a8f5
  # 1/4--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 2x2 islow/4x4 islow
shun-iwasawa 82a8f5
  #         ENT: huff
shun-iwasawa 82a8f5
  # 1/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 1x1 islow/2x2 islow
shun-iwasawa 82a8f5
  #         ENT: huff
shun-iwasawa 82a8f5
  foreach(scale 2_1 15_8 13_8 11_8 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8)
shun-iwasawa 82a8f5
    string(REGEX REPLACE "_" "/" scalearg ${scale})
shun-iwasawa 82a8f5
    add_bittest(djpeg 420m-islow-${scale}
shun-iwasawa 82a8f5
      "-dct;int;-scale;${scalearg};-nosmooth;-ppm"
shun-iwasawa 82a8f5
      testout_420m_islow_${scale}.ppm ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
      ${MD5_PPM_420M_ISLOW_${scale}})
shun-iwasawa 82a8f5
  endforeach()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  if(NOT WITH_12BIT)
shun-iwasawa 82a8f5
    # CC: YCC->RGB (dithered)  SAMP: h2v2 fancy  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 420-islow-256 "-dct;int;-colors;256;-bmp"
shun-iwasawa 82a8f5
      testout_420_islow_256.bmp ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
      ${MD5_BMP_420_ISLOW_256})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: YCC->RGB565  SAMP: h2v2 fancy  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 420-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
shun-iwasawa 82a8f5
      testout_420_islow_565.bmp ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
      ${MD5_BMP_420_ISLOW_565})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: YCC->RGB565 (dithered)  SAMP: h2v2 fancy  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 420-islow-565D "-dct;int;-rgb565;-bmp"
shun-iwasawa 82a8f5
      testout_420_islow_565D.bmp ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
      ${MD5_BMP_420_ISLOW_565D})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: YCC->RGB565  SAMP: h2v2 merged  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 420m-islow-565
shun-iwasawa 82a8f5
      "-dct;int;-nosmooth;-rgb565;-dither;none;-bmp"
shun-iwasawa 82a8f5
      testout_420m_islow_565.bmp ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
      ${MD5_BMP_420M_ISLOW_565})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
    # CC: YCC->RGB565 (dithered)  SAMP: h2v2 merged  IDCT: islow  ENT: huff
shun-iwasawa 82a8f5
    add_bittest(djpeg 420m-islow-565D "-dct;int;-nosmooth;-rgb565;-bmp"
shun-iwasawa 82a8f5
      testout_420m_islow_565D.bmp ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
      ${MD5_BMP_420M_ISLOW_565D})
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Partial decode tests.  These tests are designed to cover all of the
shun-iwasawa 82a8f5
  # possible code paths in jpeg_skip_scanlines().
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Context rows: Yes  Intra-iMCU row: Yes  iMCU row prefetch: No   ENT: huff
shun-iwasawa 82a8f5
  add_bittest(djpeg 420-islow-skip15_31 "-dct;int;-skip;15,31;-ppm"
shun-iwasawa 82a8f5
    testout_420_islow_skip15,31.ppm ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
    ${MD5_PPM_420_ISLOW_SKIP15_31})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Context rows: Yes  Intra-iMCU row: No   iMCU row prefetch: Yes  ENT: arith
shun-iwasawa 82a8f5
  if(WITH_ARITH_DEC)
shun-iwasawa 82a8f5
    add_bittest(djpeg 420-islow-ari-skip16_139 "-dct;int;-skip;16,139;-ppm"
shun-iwasawa 82a8f5
      testout_420_islow_ari_skip16,139.ppm ${TESTIMAGES}/testimgari.jpg
shun-iwasawa 82a8f5
      ${MD5_PPM_420_ISLOW_ARI_SKIP16_139})
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Context rows: Yes  Intra-iMCU row: No   iMCU row prefetch: No   ENT: prog huff
shun-iwasawa 82a8f5
  add_test(cjpeg-${libtype}-420-islow-prog
shun-iwasawa 82a8f5
    ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog
shun-iwasawa 82a8f5
      -outfile testout_420_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
shun-iwasawa 82a8f5
  add_bittest(djpeg 420-islow-prog-crop62x62_71_71
shun-iwasawa 82a8f5
    "-dct;int;-crop;62x62+71+71;-ppm"
shun-iwasawa 82a8f5
    testout_420_islow_prog_crop62x62,71,71.ppm testout_420_islow_prog.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71} cjpeg-${libtype}-420-islow-prog)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Context rows: Yes  Intra-iMCU row: No   iMCU row prefetch: No   ENT: arith
shun-iwasawa 82a8f5
  if(WITH_ARITH_DEC)
shun-iwasawa 82a8f5
    add_bittest(djpeg 420-islow-ari-crop53x53_4_4
shun-iwasawa 82a8f5
      "-dct;int;-crop;53x53+4+4;-ppm"
shun-iwasawa 82a8f5
      testout_420_islow_ari_crop53x53,4,4.ppm ${TESTIMAGES}/testimgari.jpg
shun-iwasawa 82a8f5
      ${MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4})
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Context rows: No   Intra-iMCU row: Yes  ENT: huff
shun-iwasawa 82a8f5
  add_test(cjpeg-${libtype}-444-islow
shun-iwasawa 82a8f5
    ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -sample 1x1
shun-iwasawa 82a8f5
      -outfile testout_444_islow.jpg ${TESTIMAGES}/testorig.ppm)
shun-iwasawa 82a8f5
  add_bittest(djpeg 444-islow-skip1_6 "-dct;int;-skip;1,6;-ppm"
shun-iwasawa 82a8f5
    testout_444_islow_skip1,6.ppm testout_444_islow.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_444_ISLOW_SKIP1_6} cjpeg-${libtype}-444-islow)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Context rows: No   Intra-iMCU row: No   ENT: prog huff
shun-iwasawa 82a8f5
  add_test(cjpeg-${libtype}-444-islow-prog
shun-iwasawa 82a8f5
    ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog -sample 1x1
shun-iwasawa 82a8f5
      -outfile testout_444_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
shun-iwasawa 82a8f5
  add_bittest(djpeg 444-islow-prog-crop98x98_13_13
shun-iwasawa 82a8f5
    "-dct;int;-crop;98x98+13+13;-ppm"
shun-iwasawa 82a8f5
    testout_444_islow_prog_crop98x98,13,13.ppm testout_444_islow_prog.jpg
shun-iwasawa 82a8f5
    ${MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13} cjpeg-${libtype}-444-islow-prog)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  # Context rows: No   Intra-iMCU row: No   ENT: arith
shun-iwasawa 82a8f5
  if(WITH_ARITH_ENC)
shun-iwasawa 82a8f5
    add_test(cjpeg-${libtype}-444-islow-ari
shun-iwasawa 82a8f5
      ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -arithmetic
shun-iwasawa 82a8f5
        -sample 1x1 -outfile testout_444_islow_ari.jpg
shun-iwasawa 82a8f5
        ${TESTIMAGES}/testorig.ppm)
shun-iwasawa 82a8f5
    if(WITH_ARITH_DEC)
shun-iwasawa 82a8f5
      add_bittest(djpeg 444-islow-ari-crop37x37_0_0
shun-iwasawa 82a8f5
        "-dct;int;-crop;37x37+0+0;-ppm"
shun-iwasawa 82a8f5
        testout_444_islow_ari_crop37x37,0,0.ppm testout_444_islow_ari.jpg
shun-iwasawa 82a8f5
        ${MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0} cjpeg-${libtype}-444-islow-ari)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
  add_bittest(jpegtran crop "-crop;120x90+20+50;-transpose;-perfect"
shun-iwasawa 82a8f5
    testout_crop.jpg ${TESTIMAGES}/${TESTORIG}
shun-iwasawa 82a8f5
    ${MD5_JPEG_CROP})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
endforeach()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/cmakescripts/testclean.cmake)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
configure_file(croptest.in croptest @ONLY)
shun-iwasawa 82a8f5
add_custom_target(croptest
shun-iwasawa 82a8f5
  COMMAND echo croptest
shun-iwasawa 82a8f5
  COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/croptest)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_TURBOJPEG)
shun-iwasawa 82a8f5
  configure_file(tjbenchtest.in tjbenchtest @ONLY)
shun-iwasawa 82a8f5
  configure_file(tjexampletest.in tjexampletest @ONLY)
shun-iwasawa 82a8f5
  if(WIN32)
shun-iwasawa 82a8f5
    set(BASH bash)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  if(WITH_JAVA)
shun-iwasawa 82a8f5
    configure_file(tjbenchtest.java.in tjbenchtest.java @ONLY)
shun-iwasawa 82a8f5
    configure_file(tjexampletest.java.in tjexampletest.java @ONLY)
shun-iwasawa 82a8f5
    add_custom_target(tjtest
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -alloc
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -alloc
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -yuv
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -yuv -alloc
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -progressive
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -progressive -yuv
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
shun-iwasawa 82a8f5
      COMMAND echo tjexampletest
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest.java
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest.java -yuv
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -yuv
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest.java -progressive
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -progressive
shun-iwasawa 82a8f5
      COMMAND echo tjexampletest.java -progressive -yuv
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
shun-iwasawa 82a8f5
        -progressive -yuv
shun-iwasawa 82a8f5
      COMMAND echo tjexampletest.java
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java
shun-iwasawa 82a8f5
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
shun-iwasawa 82a8f5
        ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
shun-iwasawa 82a8f5
        ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest)
shun-iwasawa 82a8f5
  else()
shun-iwasawa 82a8f5
    add_custom_target(tjtest
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -alloc
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -alloc
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -yuv
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -yuv -alloc
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -progressive
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
shun-iwasawa 82a8f5
      COMMAND echo tjbenchtest -progressive -yuv
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
shun-iwasawa 82a8f5
      COMMAND echo tjexampletest
shun-iwasawa 82a8f5
      COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
shun-iwasawa 82a8f5
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
# INSTALLATION
shun-iwasawa 82a8f5
###############################################################################
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(WITH_TURBOJPEG)
shun-iwasawa 82a8f5
  if(ENABLE_SHARED)
shun-iwasawa 82a8f5
    install(TARGETS turbojpeg tjbench
shun-iwasawa 82a8f5
      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
shun-iwasawa 82a8f5
      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
shun-iwasawa 82a8f5
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
shun-iwasawa 82a8f5
    if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
shun-iwasawa 82a8f5
      CMAKE_C_LINKER_SUPPORTS_PDB)
shun-iwasawa 82a8f5
      install(FILES "$<target_pdb_file:turbojpeg>"</target_pdb_file:turbojpeg>
shun-iwasawa 82a8f5
        DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  if(ENABLE_STATIC)
shun-iwasawa 82a8f5
    install(TARGETS turbojpeg-static ARCHIVE
shun-iwasawa 82a8f5
      DESTINATION ${CMAKE_INSTALL_LIBDIR})
shun-iwasawa 82a8f5
    if(NOT ENABLE_SHARED)
shun-iwasawa 82a8f5
      if(MSVC_IDE OR XCODE)
shun-iwasawa 82a8f5
        set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
shun-iwasawa 82a8f5
      else()
shun-iwasawa 82a8f5
        set(DIR ${CMAKE_CURRENT_BINARY_DIR})
shun-iwasawa 82a8f5
      endif()
shun-iwasawa 82a8f5
      install(PROGRAMS ${DIR}/tjbench-static${EXE}
shun-iwasawa 82a8f5
        DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h
shun-iwasawa 82a8f5
    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(ENABLE_STATIC)
shun-iwasawa 82a8f5
  install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
shun-iwasawa 82a8f5
  if(NOT ENABLE_SHARED)
shun-iwasawa 82a8f5
    if(MSVC_IDE OR XCODE)
shun-iwasawa 82a8f5
      set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
shun-iwasawa 82a8f5
    else()
shun-iwasawa 82a8f5
      set(DIR ${CMAKE_CURRENT_BINARY_DIR})
shun-iwasawa 82a8f5
    endif()
shun-iwasawa 82a8f5
    install(PROGRAMS ${DIR}/cjpeg-static${EXE}
shun-iwasawa 82a8f5
      DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
shun-iwasawa 82a8f5
    install(PROGRAMS ${DIR}/djpeg-static${EXE}
shun-iwasawa 82a8f5
      DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
shun-iwasawa 82a8f5
    install(PROGRAMS ${DIR}/jpegtran-static${EXE}
shun-iwasawa 82a8f5
      DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
shun-iwasawa 82a8f5
  endif()
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/tjexample.c
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/structure.txt
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/wizard.txt
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
shun-iwasawa 82a8f5
if(WITH_JAVA)
shun-iwasawa 82a8f5
  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java
shun-iwasawa 82a8f5
    DESTINATION ${CMAKE_INSTALL_DOCDIR})
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
if(UNIX OR MINGW)
shun-iwasawa 82a8f5
  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cjpeg.1
shun-iwasawa 82a8f5
    ${CMAKE_CURRENT_SOURCE_DIR}/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/jpegtran.1
shun-iwasawa 82a8f5
    ${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
shun-iwasawa 82a8f5
    ${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
shun-iwasawa 82a8f5
    DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
shun-iwasawa 82a8f5
endif()
shun-iwasawa 82a8f5
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
shun-iwasawa 82a8f5
  DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
shun-iwasawa 82a8f5
  ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h
shun-iwasawa 82a8f5
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
include(cmakescripts/BuildPackages.cmake)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in"
shun-iwasawa 82a8f5
  "cmake_uninstall.cmake" IMMEDIATE @ONLY)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)