Warning, /graphics/krita/cmake/modules/MacroJPEG.cmake is written in an unsupported language. File is not indexed.
0001 # A macro wrapper to find JPEG library version
0002 #
0003 # Syntax: DETECT_JPEG()
0004 # JPEG_LIB_VERSION is set to version ID depending of libjpeg version detected.
0005 #
0006 # SPDX-FileCopyrightText: 2010-2014 Gilles Caulier <caulier dot gilles at gmail dot com>
0007 #
0008 # SPDX-License-Identifier: BSD-3-Clause
0009 #
0010 # check version of libjpeg so that we can use the appropriate dir
0011 # See bug #227313 for details
0012
0013 function(CompileToCheckVersion LibId Ret)
0014
0015 set(_jpeglib_version_source "
0016 #include <stddef.h>
0017 #include <stdio.h>
0018 #include <jpeglib.h>
0019 int main()
0020 {
0021 #if (JPEG_LIB_VERSION >= ${LibId})
0022 #error JPEG_LIB_VERSION >= ${LibId}
0023 #endif
0024 }
0025 ")
0026
0027 set(_jpeglib_version_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/cmake_jpeglib_version_check.cpp)
0028 file(WRITE "${_jpeglib_version_source_file}" "${_jpeglib_version_source}")
0029 set(_jpeglib_version_include_dirs "-DINCLUDE_DIRECTORIES:STRING=${JPEG_INCLUDE_DIR}")
0030
0031 try_compile(_jpeglib_version_compile_result ${CMAKE_BINARY_DIR} ${_jpeglib_version_source_file}
0032 CMAKE_FLAGS "${_jpeglib_version_include_dirs}"
0033 COMPILE_OUTPUT_VARIABLE _jpeglib_version_compile_output_var)
0034
0035 set(${Ret} ${_jpeglib_version_compile_result} PARENT_SCOPE)
0036
0037 endfunction()
0038
0039 macro(DETECT_JPEG)
0040
0041 find_package(JPEG REQUIRED)
0042
0043 if(JPEG_FOUND)
0044
0045 CompileToCheckVersion(90 _CompileResult)
0046
0047 if(_CompileResult)
0048
0049 # Compile successfully. It's not libjpeg 90. We check previous version.
0050
0051 CompileToCheckVersion(80 _CompileResult)
0052
0053 if(_CompileResult)
0054
0055 # Compile successfully. It's not libjpeg 90. We check previous version.
0056
0057 CompileToCheckVersion(70 _CompileResult)
0058
0059 if(_CompileResult)
0060
0061 # Compile successfully. It's not libjpeg 70.
0062 set(JPEG_LIB_VERSION 62)
0063
0064 else()
0065
0066 set(JPEG_LIB_VERSION 70)
0067
0068 endif()
0069
0070 else()
0071
0072 set(JPEG_LIB_VERSION 84)
0073
0074 endif()
0075
0076 else()
0077
0078 set(JPEG_LIB_VERSION 91)
0079
0080 endif()
0081
0082 message(STATUS "Libjpeg version: ${JPEG_LIB_VERSION}")
0083
0084 endif()
0085
0086 endmacro()