~shnatsel/+junk/extra-cmake-modules-backport

« back to all changes in this revision

Viewing changes to attic/modules/FindLCMS.cmake

  • Committer: Sergey "Shnatsel" Davidoff
  • Date: 2016-04-18 20:49:08 UTC
  • Revision ID: shnatsel@gmail.com-20160418204908-x2k7rm6hewpwhugg
Initial import of version 5.9.0-0ubuntu1 from vivid

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# - Find LCMS
 
2
# Find the LCMS (Little Color Management System) library and includes and
 
3
# This module defines
 
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.
 
9
#
 
10
# The minimum required version of LCMS can be specified using the
 
11
# standard syntax, e.g. find_package(LCMS 1.10)
 
12
 
 
13
# Copyright (c) 2008, Adrian Page, <adrian@pagenet.plus.com>
 
14
# Copyright (c) 2009, Cyrille Berger, <cberger@cberger.net>
 
15
#
 
16
# Redistribution and use is allowed according to the terms of the BSD license.
 
17
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
18
 
 
19
 
 
20
# use pkg-config to get the directories and then use these values
 
21
# in the FIND_PATH() and FIND_LIBRARY() calls
 
22
if(NOT WIN32)
 
23
   find_package(PkgConfig)
 
24
   pkg_check_modules(PC_LCMS lcms)
 
25
   set(LCMS_DEFINITIONS ${PC_LCMS_CFLAGS_OTHER})
 
26
endif(NOT WIN32)
 
27
 
 
28
find_path(LCMS_INCLUDE_DIR lcms.h
 
29
   HINTS
 
30
   ${PC_LCMS_INCLUDEDIR}
 
31
   ${PC_LCMS_INCLUDE_DIRS}
 
32
   PATH_SUFFIXES lcms liblcms1
 
33
)
 
34
 
 
35
find_library(LCMS_LIBRARIES NAMES lcms liblcms lcms-1 liblcms-1
 
36
   HINTS
 
37
   ${PC_LCMS_LIBDIR}
 
38
   ${PC_LCMS_LIBRARY_DIRS}
 
39
   PATH_SUFFIXES lcms
 
40
)
 
41
 
 
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)
 
54
 
 
55
include(FindPackageHandleStandardArgs)
 
56
find_package_handle_standard_args(LCMS REQUIRED_VARS LCMS_LIBRARIES LCMS_INCLUDE_DIR
 
57
                                       VERSION_VAR LCMS_DOT_VERSION )
 
58
 
 
59
mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARIES LCMS_VERSION)
 
60