summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindLCMS2.cmake
blob: d02515815d5daf238cc90545b4592d12a1681120 (plain)
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
#.rst:
# FindLCMS2
# -----------
# Finds the LCMS Color Management library
#
# This will define the following variables::
#
# LCMS2_FOUND - system has LCMS Color Management
# LCMS2_INCLUDE_DIRS - the LCMS Color Management include directory
# LCMS2_LIBRARIES - the LCMS Color Management libraries
# LCMS2_DEFINITIONS - the LCMS Color Management definitions
#
# and the following imported targets::
#
#   LCMS2::LCMS2   - The LCMS Color Management library

if(PKG_CONFIG_FOUND)
  pkg_check_modules(PC_LCMS2 lcms2>=2.10 QUIET)
endif()

find_path(LCMS2_INCLUDE_DIR NAMES lcms2.h
                            PATHS ${PC_LCMS2_INCLUDEDIR})
find_library(LCMS2_LIBRARY NAMES lcms2 liblcms2
                           PATHS ${PC_LCMS2_LIBDIR})

set(LCMS2_VERSION ${PC_LCMS2_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LCMS2
                                  REQUIRED_VARS LCMS2_LIBRARY LCMS2_INCLUDE_DIR
                                  VERSION_VAR LCMS2_VERSION)

if(LCMS2_FOUND)
  set(LCMS2_LIBRARIES ${LCMS2_LIBRARY})
  set(LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
  set(LCMS2_DEFINITIONS -DHAVE_LCMS2=1 -DCMS_NO_REGISTER_KEYWORD=1)

  if(NOT TARGET LCMS2::LCMS2)
    add_library(LCMS2::LCMS2 UNKNOWN IMPORTED)
    set_target_properties(LCMS2::LCMS2 PROPERTIES
                                       IMPORTED_LOCATION "${LCMS2_LIBRARY}"
                                       INTERFACE_INCLUDE_DIRECTORIES "${LCMS2_INCLUDE_DIR}"
                                       INTERFACE_COMPILE_DEFINITIONS HAVE_LCMS2=1)
  endif()
endif()

mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)