| 1 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
# file Copyright.txt or https://cmake.org/licensing for details. |
| 3 |
|
| 4 |
#[=======================================================================[.rst: |
| 5 |
FindJBIG |
| 6 |
-------- |
| 7 |
|
| 8 |
Find the native JBIG includes and library. |
| 9 |
|
| 10 |
IMPORTED Targets |
| 11 |
^^^^^^^^^^^^^^^^ |
| 12 |
|
| 13 |
This module defines :prop_tgt:`IMPORTED` target ``JBIG::JBIG``, if |
| 14 |
JBIG has been found. |
| 15 |
|
| 16 |
Result Variables |
| 17 |
^^^^^^^^^^^^^^^^ |
| 18 |
|
| 19 |
This module defines the following variables: |
| 20 |
|
| 21 |
:: |
| 22 |
|
| 23 |
JBIG_INCLUDE_DIRS - where to find jbig.h, etc. |
| 24 |
JBIG_LIBRARIES - List of libraries when using jbig. |
| 25 |
JBIG_FOUND - True if jbig found. |
| 26 |
|
| 27 |
:: |
| 28 |
|
| 29 |
JBIG_VERSION_STRING - The version of jbig found (x.y.z) |
| 30 |
JBIG_VERSION_MAJOR - The major version of jbig |
| 31 |
JBIG_VERSION_MINOR - The minor version of jbig |
| 32 |
|
| 33 |
Debug and Release variants are found separately. |
| 34 |
#]=======================================================================] |
| 35 |
|
| 36 |
# Standard names to search for |
| 37 |
set(JBIG_NAMES jbig) |
| 38 |
set(JBIG_NAMES_DEBUG jbigd) |
| 39 |
|
| 40 |
find_path(JBIG_INCLUDE_DIR |
| 41 |
NAMES jbig.h |
| 42 |
PATH_SUFFIXES include) |
| 43 |
|
| 44 |
set(JBIG_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") |
| 45 |
# Library has a "lib" prefix even on Windows. |
| 46 |
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") |
| 47 |
|
| 48 |
# Allow JBIG_LIBRARY to be set manually, as the location of the jbig library |
| 49 |
if(NOT JBIG_LIBRARY) |
| 50 |
find_library(JBIG_LIBRARY_RELEASE |
| 51 |
NAMES ${JBIG_NAMES} |
| 52 |
PATH_SUFFIXES lib) |
| 53 |
find_library(JBIG_LIBRARY_DEBUG |
| 54 |
NAMES ${JBIG_NAMES_DEBUG} |
| 55 |
PATH_SUFFIXES lib) |
| 56 |
|
| 57 |
include(SelectLibraryConfigurations) |
| 58 |
select_library_configurations(JBIG) |
| 59 |
endif() |
| 60 |
|
| 61 |
set(CMAKE_FIND_LIBRARY_PREFIXES "${JBIG_OLD_FIND_LIBRARY_PREFIXES}") |
| 62 |
|
| 63 |
unset(JBIG_NAMES) |
| 64 |
unset(JBIG_NAMES_DEBUG) |
| 65 |
unset(JBIG_OLD_FIND_LIBRARY_PREFIXES) |
| 66 |
|
| 67 |
mark_as_advanced(JBIG_INCLUDE_DIR) |
| 68 |
|
| 69 |
if(JBIG_INCLUDE_DIR AND EXISTS "${JBIG_INCLUDE_DIR}/jbig.h") |
| 70 |
file(STRINGS "${JBIG_INCLUDE_DIR}/jbig.h" JBIG_H REGEX "^#define JBG_VERSION *\"[^\"]*\"$") |
| 71 |
|
| 72 |
string(REGEX REPLACE "^.*JBG_VERSION *\"([0-9]+).*$" "\\1" JBIG_MAJOR_VERSION "${JBIG_H}") |
| 73 |
string(REGEX REPLACE "^.*JBG_VERSION *\"[0-9]+\\.([0-9]+).*$" "\\1" JBIG_MINOR_VERSION "${JBIG_H}") |
| 74 |
set(JBIG_VERSION_STRING "${JBIG_MAJOR_VERSION}.${JBIG_MINOR_VERSION}") |
| 75 |
|
| 76 |
set(JBIG_MAJOR_VERSION "${JBIG_VERSION_MAJOR}") |
| 77 |
set(JBIG_MINOR_VERSION "${JBIG_VERSION_MINOR}") |
| 78 |
endif() |
| 79 |
|
| 80 |
include(FindPackageHandleStandardArgs) |
| 81 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JBIG |
| 82 |
REQUIRED_VARS JBIG_LIBRARY JBIG_INCLUDE_DIR |
| 83 |
VERSION_VAR JBIG_VERSION_STRING) |
| 84 |
|
| 85 |
if(JBIG_FOUND) |
| 86 |
set(JBIG_INCLUDE_DIRS ${JBIG_INCLUDE_DIR}) |
| 87 |
|
| 88 |
if(NOT JBIG_LIBRARIES) |
| 89 |
set(JBIG_LIBRARIES ${JBIG_LIBRARY}) |
| 90 |
endif() |
| 91 |
|
| 92 |
if(NOT TARGET JBIG::JBIG) |
| 93 |
add_library(JBIG::JBIG UNKNOWN IMPORTED) |
| 94 |
set_target_properties(JBIG::JBIG PROPERTIES |
| 95 |
INTERFACE_INCLUDE_DIRECTORIES "${JBIG_INCLUDE_DIRS}") |
| 96 |
|
| 97 |
if(JBIG_LIBRARY_RELEASE) |
| 98 |
set_property(TARGET JBIG::JBIG APPEND PROPERTY |
| 99 |
IMPORTED_CONFIGURATIONS RELEASE) |
| 100 |
set_target_properties(JBIG::JBIG PROPERTIES |
| 101 |
IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY_RELEASE}") |
| 102 |
endif() |
| 103 |
|
| 104 |
if(JBIG_LIBRARY_DEBUG) |
| 105 |
set_property(TARGET JBIG::JBIG APPEND PROPERTY |
| 106 |
IMPORTED_CONFIGURATIONS DEBUG) |
| 107 |
set_target_properties(JBIG::JBIG PROPERTIES |
| 108 |
IMPORTED_LOCATION_DEBUG "${JBIG_LIBRARY_DEBUG}") |
| 109 |
endif() |
| 110 |
|
| 111 |
if(NOT JBIG_LIBRARY_RELEASE AND NOT JBIG_LIBRARY_DEBUG) |
| 112 |
set_target_properties(JBIG::JBIG PROPERTIES |
| 113 |
IMPORTED_LOCATION "${JBIG_LIBRARY}") |
| 114 |
endif() |
| 115 |
endif() |
| 116 |
endif() |