forked from Eyescale/CMake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindLibJpegTurbo.cmake
75 lines (67 loc) · 2.66 KB
/
FindLibJpegTurbo.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# - Try to find libjpeg-turbo
# Once done, this will define
#
# LibJpegTurbo_FOUND - system has libjpeg-turbo
# LibJpegTurbo_INCLUDE_DIRS - the libjpeg-turbo include directories
# LibJpegTurbo_LIBRARIES - link these to use libjpeg-turbo
# LibJpegTurbo_VERSION - the version of libjpeg-turbo
#
# this file is modelled after http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
include(LibFindMacros)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(LibJpegTurbo_PKGCONF LibJpegTurbo)
if(NOT LibJpegTurbo_PKGCONF_FOUND)
libfind_pkg_check_modules(LibJpegTurbo_PKGCONF libturbojpeg)
endif()
# Include dir
find_path(LibJpegTurbo_INCLUDE_DIR
NAMES turbojpeg.h
PATHS ${LibJpegTurbo_PKGCONF_INCLUDE_DIRS} /opt/libjpeg-turbo/include $ENV{LIBJPEGTURBO_ROOT}/include
)
# Search for header with version: jconfig.h
if(LibJpegTurbo_INCLUDE_DIR)
if(EXISTS "${LibJpegTurbo_INCLUDE_DIR}/jconfig-64.h")
set(_version_header "${LibJpegTurbo_INCLUDE_DIR}/jconfig-64.h")
elseif(EXISTS "${LibJpegTurbo_INCLUDE_DIR}/jconfig.h")
set(_version_header "${LibJpegTurbo_INCLUDE_DIR}/jconfig.h")
elseif(EXISTS "${LibJpegTurbo_INCLUDE_DIR}/x86_64-linux-gnu/jconfig.h")
set(_version_header "${LibJpegTurbo_INCLUDE_DIR}/x86_64-linux-gnu/jconfig.h")
else()
set(_version_header)
if(NOT LibJpegTurbo_FIND_QUIETLY)
message(STATUS "Could not find 'jconfig.h' to check version")
endif()
endif()
endif()
# Found the header, read version
if(_version_header)
file(READ "${_version_header}" _header)
if(_header)
string(REGEX REPLACE ".*#define[\t ]+LIBJPEG_TURBO_VERSION[\t ]+([0-9.]+).*"
"\\1" LibJpegTurbo_VERSION "${_header}")
endif()
unset(_header)
endif()
# Finally the library itself
find_library(LibJpegTurbo_LIBRARY
NAMES libturbojpeg.so libturbojpeg.so.0 turbojpeg.lib libturbojpeg.dylib
PATHS ${LibJpegTurbo_PKGCONF_LIBRARY_DIRS} /opt/libjpeg-turbo/lib $ENV{LIBJPEGTURBO_ROOT}/lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibJpegTurbo FOUND_VAR LibJpegTurbo_FOUND
REQUIRED_VARS LibJpegTurbo_LIBRARY
LibJpegTurbo_INCLUDE_DIR LibJpegTurbo_VERSION
VERSION_VAR LibJpegTurbo_VERSION)
if(LibJpegTurbo_FOUND)
set(LibJpegTurbo_INCLUDE_DIRS ${LibJpegTurbo_INCLUDE_DIR})
set(LibJpegTurbo_LIBRARIES ${LibJpegTurbo_LIBRARY})
if(NOT LibJpegTurbo_FIND_QUIETLY)
message(STATUS "Found LibJpegTurbo in ${LibJpegTurbo_INCLUDE_DIR}:${LibJpegTurbo_LIBRARIES}")
endif()
else()
set(LibJpegTurbo_INCLUDE_DIR)
set(LibJpegTurbo_INCLUDE_DIRS)
set(LibJpegTurbo_LIBRARY)
set(LibJpegTurbo_LIBRARIES)
set(LibJpegTurbo_VERSION)
endif()