Code

Cmake: Find Dependencies rebuilt
[inkscape.git] / CMakeScripts / FindLCMS.cmake
1 # - Try to find LCMS
2 # Once done this will define
3 #
4 #  LCMS_FOUND - system has LCMS
5 #  LCMS_INCLUDE_DIRS - the LCMS include directory
6 #  LCMS_LIBRARIES - Link these to use LCMS
7 #  LCMS_DEFINITIONS - Compiler switches required for using LCMS
8 #
9 #  Copyright (c) 2008 Joshua L. Blocher <verbalshadow@gmail.com>
10 #
11 #  Redistribution and use is allowed according to the terms of the New
12 #  BSD license.
13 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 #
17 if (LCMS_LIBRARIES AND LCMS_INCLUDE_DIRS)
18   # in cache already
19   set(LCMS_FOUND TRUE)
20 else (LCMS_LIBRARIES AND LCMS_INCLUDE_DIRS)
21   # use pkg-config to get the directories and then use these values
22   # in the FIND_PATH() and FIND_LIBRARY() calls
23   if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
24     include(UsePkgConfig)
25     pkgconfig(lcms _LCMS_INCLUDEDIR _LCMS_LIBDIR _LCMS_LDFLAGS _LCMS_CFLAGS)
26   else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
27     find_package(PkgConfig)
28     if (PKG_CONFIG_FOUND)
29       pkg_check_modules(_LCMS lcms)
30     endif (PKG_CONFIG_FOUND)
31   endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
32   find_path(LCMS_INCLUDE_DIR
33     NAMES
34       lcms.h
35     PATHS
36       ${_LCMS_INCLUDEDIR}
37       /usr/include
38       /usr/local/include
39       /opt/local/include
40       /sw/include
41     PATH_SUFFIXES
42       lcms
43   )
45   find_library(LCMS_LIBRARY
46     NAMES
47       lcms
48     PATHS
49       ${_LCMS_LIBDIR}
50       /usr/lib
51       /usr/local/lib
52       /opt/local/lib
53       /sw/lib
54   )
56   if (LCMS_LIBRARY)
57     set(LCMS_FOUND TRUE)
58   endif (LCMS_LIBRARY)
60   set(LCMS_INCLUDE_DIRS
61     ${LCMS_INCLUDE_DIR}
62   )
64   if (LCMS_FOUND)
65     set(LCMS_LIBRARIES
66       ${LCMS_LIBRARIES}
67       ${LCMS_LIBRARY}
68     )
69   endif (LCMS_FOUND)
71   if (LCMS_INCLUDE_DIRS AND LCMS_LIBRARIES)
72      set(LCMS_FOUND TRUE)
73   endif (LCMS_INCLUDE_DIRS AND LCMS_LIBRARIES)
75   if (LCMS_FOUND)
76     if (NOT LCMS_FIND_QUIETLY)
77       message(STATUS "Found LCMS: ${LCMS_LIBRARIES}")
78     endif (NOT LCMS_FIND_QUIETLY)
79   else (LCMS_FOUND)
80     if (LCMS_FIND_REQUIRED)
81       message(FATAL_ERROR "Could not find LCMS")
82     endif (LCMS_FIND_REQUIRED)
83   endif (LCMS_FOUND)
85   # show the LCMS_INCLUDE_DIRS and LCMS_LIBRARIES variables only in the advanced view
86   mark_as_advanced(LCMS_INCLUDE_DIRS LCMS_LIBRARIES)
88 endif (LCMS_LIBRARIES AND LCMS_INCLUDE_DIRS)