summaryrefslogtreecommitdiff
path: root/cmake/modules/FindLIBOPENJPEG.cmake
blob: d9c1369607338dd54477f84e84c65d233dfc4821 (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
49
50
51
52
53
# - Try to find the libopenjpeg library
# Once done this will define
#
#  LIBOPENJPEG_FOUND - system has libopenjpeg
#  LIBOPENJPEG_INCLUDE_DIRS - the libopenjpeg include directories
#  LIBOPENJPEG_LIBRARIES - Link these to use libopenjpeg
#  LIBOPENJPEG_INCLUDE_DIR is internal and deprecated for use

# Copyright (c) 2008, Albert Astals Cid, <aacid@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.


if (LIBOPENJPEG_LIBRARIES AND LIBOPENJPEG_INCLUDE_DIR)

  # in cache already
  set(LIBOPENJPEG_FOUND TRUE)

else (LIBOPENJPEG_LIBRARIES AND LIBOPENJPEG_INCLUDE_DIR)

  #reset vars
  set(LIBOPENJPEG_LIBRARIES)
  set(LIBOPENJPEG_INCLUDE_DIR)

  find_path (LIBOPENJPEG_INCLUDE_DIR openjpeg.h PATH_SUFFIXES openjpeg)
  find_library(LIBOPENJPEG_LIBRARIES openjpeg)
  if(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES)

  set(CMAKE_REQUIRED_INCLUDES ${LIBOPENJPEG_INCLUDE_DIR})
  set(CMAKE_REQUIRED_LIBRARIES ${LIBOPENJPEG_LIBRARIES})

check_cxx_source_compiles("
#include <openjpeg.h>
int main()
{
  int foo = OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
  return 0;
}
" WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG)

  set(CMAKE_REQUIRED_INCLUDES)
  set(CMAKE_REQUIRED_LIBRARIES)

    set(LIBOPENJPEG_FOUND TRUE)
  endif(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES)

  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(LibOpenJPEG DEFAULT_MSG LIBOPENJPEG_LIBRARIES LIBOPENJPEG_INCLUDE_DIR)

endif (LIBOPENJPEG_LIBRARIES AND LIBOPENJPEG_INCLUDE_DIR)

set(LIBOPENJPEG_INCLUDE_DIRS ${LIBOPENJPEG_INCLUDE_DIR})