2
# Find the LCMS (Little Color Management System) library and includes and
4
# LCMS_INCLUDE_DIR, where to find lcms.h
5
# LCMS_LIBRARIES, the libraries needed to use LCMS.
6
# LCMS_DOT_VERSION, The version number of the LCMS library, e.g. "1.19"
7
# LCMS_VERSION, Similar to LCMS_DOT_VERSION, but without the dots, e.g. "119"
8
# LCMS_FOUND, If false, do not try to use LCMS.
10
# The minimum required version of LCMS can be specified using the
11
# standard syntax, e.g. find_package(LCMS 1.10)
13
# Copyright (c) 2008, Adrian Page, <adrian@pagenet.plus.com>
14
# Copyright (c) 2009, Cyrille Berger, <cberger@cberger.net>
16
# Redistribution and use is allowed according to the terms of the BSD license.
17
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
20
# use pkg-config to get the directories and then use these values
21
# in the FIND_PATH() and FIND_LIBRARY() calls
23
find_package(PkgConfig)
24
pkg_check_modules(PC_LCMS lcms)
25
set(LCMS_DEFINITIONS ${PC_LCMS_CFLAGS_OTHER})
28
find_path(LCMS_INCLUDE_DIR lcms.h
31
${PC_LCMS_INCLUDE_DIRS}
32
PATH_SUFFIXES lcms liblcms1
35
find_library(LCMS_LIBRARIES NAMES lcms liblcms lcms-1 liblcms-1
38
${PC_LCMS_LIBRARY_DIRS}
42
# Store the LCMS version number in the cache, so we don't have to search everytime again
43
if(LCMS_INCLUDE_DIR AND NOT LCMS_VERSION)
44
file(READ ${LCMS_INCLUDE_DIR}/lcms.h LCMS_VERSION_CONTENT)
45
string(REGEX MATCH "#define LCMS_VERSION[ ]*[0-9]*\n" LCMS_VERSION_MATCH ${LCMS_VERSION_CONTENT})
46
if(LCMS_VERSION_MATCH)
47
string(REGEX REPLACE "#define LCMS_VERSION[ ]*([0-9]*)\n" "\\1" _LCMS_VERSION ${LCMS_VERSION_MATCH})
48
string(SUBSTRING ${_LCMS_VERSION} 0 1 LCMS_MAJOR_VERSION)
49
string(SUBSTRING ${_LCMS_VERSION} 1 2 LCMS_MINOR_VERSION)
50
endif(LCMS_VERSION_MATCH)
51
set(LCMS_VERSION "${LCMS_MAJOR_VERSION}${LCMS_MINOR_VERSION}" CACHE STRING "Version number of lcms" FORCE)
52
set(LCMS_DOT_VERSION "${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}" CACHE STRING "Version number of lcms split into components" FORCE)
53
endif(LCMS_INCLUDE_DIR AND NOT LCMS_VERSION)
55
include(FindPackageHandleStandardArgs)
56
find_package_handle_standard_args(LCMS REQUIRED_VARS LCMS_LIBRARIES LCMS_INCLUDE_DIR
57
VERSION_VAR LCMS_DOT_VERSION )
59
mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARIES LCMS_VERSION)