| 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 |
FindDeflate |
| 6 |
-------- |
| 7 |
|
| 8 |
Find the native Deflate includes and library. |
| 9 |
|
| 10 |
IMPORTED Targets |
| 11 |
^^^^^^^^^^^^^^^^ |
| 12 |
|
| 13 |
This module defines :prop_tgt:`IMPORTED` target ``Deflate::Deflate``, if |
| 14 |
Deflate has been found. |
| 15 |
|
| 16 |
Result Variables |
| 17 |
^^^^^^^^^^^^^^^^ |
| 18 |
|
| 19 |
This module defines the following variables: |
| 20 |
|
| 21 |
:: |
| 22 |
|
| 23 |
Deflate_INCLUDE_DIRS - where to find deflate.h, etc. |
| 24 |
Deflate_LIBRARIES - List of libraries when using deflate. |
| 25 |
Deflate_FOUND - True if deflate found. |
| 26 |
|
| 27 |
:: |
| 28 |
|
| 29 |
Deflate_VERSION_STRING - The version of deflate found (x.y.z) |
| 30 |
Deflate_VERSION_MAJOR - The major version of deflate |
| 31 |
Deflate_VERSION_MINOR - The minor version of deflate |
| 32 |
|
| 33 |
Debug and Release variants are found separately. |
| 34 |
#]=======================================================================] |
| 35 |
|
| 36 |
# Standard names to search for |
| 37 |
set(Deflate_NAMES deflate deflatestatic) |
| 38 |
set(Deflate_NAMES_DEBUG deflated deflatestaticd) |
| 39 |
|
| 40 |
find_path(Deflate_INCLUDE_DIR |
| 41 |
NAMES libdeflate.h |
| 42 |
PATH_SUFFIXES include) |
| 43 |
|
| 44 |
set(Deflate_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 Deflate_LIBRARY to be set manually, as the location of the deflate library |
| 49 |
if(NOT Deflate_LIBRARY) |
| 50 |
find_library(Deflate_LIBRARY_RELEASE |
| 51 |
NAMES ${Deflate_NAMES} |
| 52 |
PATH_SUFFIXES lib) |
| 53 |
find_library(Deflate_LIBRARY_DEBUG |
| 54 |
NAMES ${Deflate_NAMES_DEBUG} |
| 55 |
PATH_SUFFIXES lib) |
| 56 |
|
| 57 |
include(SelectLibraryConfigurations) |
| 58 |
select_library_configurations(Deflate) |
| 59 |
endif() |
| 60 |
|
| 61 |
set(CMAKE_FIND_LIBRARY_PREFIXES "${Deflate_OLD_FIND_LIBRARY_PREFIXES}") |
| 62 |
|
| 63 |
unset(Deflate_NAMES) |
| 64 |
unset(Deflate_NAMES_DEBUG) |
| 65 |
unset(Deflate_OLD_FIND_LIBRARY_PREFIXES) |
| 66 |
|
| 67 |
mark_as_advanced(Deflate_INCLUDE_DIR) |
| 68 |
|
| 69 |
if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/libdeflate.h") |
| 70 |
file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define[\t ]+LIBDEFLATE_VERSION_STRING[\t ]+.*") |
| 71 |
string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]+\"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}") |
| 72 |
string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]\"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}") |
| 73 |
set(Deflate_VERSION_STRING "${Deflate_MAJOR_VERSION}.${Deflate_MINOR_VERSION}") |
| 74 |
|
| 75 |
set(Deflate_VERSION_MAJOR "${Deflate_MAJOR_VERSION}") |
| 76 |
set(Deflate_VERSION_MINOR "${Deflate_MINOR_VERSION}") |
| 77 |
endif() |
| 78 |
|
| 79 |
include(FindPackageHandleStandardArgs) |
| 80 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Deflate |
| 81 |
REQUIRED_VARS Deflate_LIBRARY Deflate_INCLUDE_DIR |
| 82 |
VERSION_VAR Deflate_VERSION_STRING) |
| 83 |
|
| 84 |
if(Deflate_FOUND) |
| 85 |
set(Deflate_INCLUDE_DIRS ${Deflate_INCLUDE_DIR}) |
| 86 |
|
| 87 |
if(NOT Deflate_LIBRARIES) |
| 88 |
set(Deflate_LIBRARIES ${Deflate_LIBRARY}) |
| 89 |
endif() |
| 90 |
|
| 91 |
if(NOT TARGET Deflate::Deflate) |
| 92 |
add_library(Deflate::Deflate UNKNOWN IMPORTED) |
| 93 |
set_target_properties(Deflate::Deflate PROPERTIES |
| 94 |
INTERFACE_INCLUDE_DIRECTORIES "${Deflate_INCLUDE_DIRS}") |
| 95 |
|
| 96 |
if(Deflate_LIBRARY_RELEASE) |
| 97 |
set_property(TARGET Deflate::Deflate APPEND PROPERTY |
| 98 |
IMPORTED_CONFIGURATIONS RELEASE) |
| 99 |
set_target_properties(Deflate::Deflate PROPERTIES |
| 100 |
IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY_RELEASE}") |
| 101 |
endif() |
| 102 |
|
| 103 |
if(Deflate_LIBRARY_DEBUG) |
| 104 |
set_property(TARGET Deflate::Deflate APPEND PROPERTY |
| 105 |
IMPORTED_CONFIGURATIONS DEBUG) |
| 106 |
set_target_properties(Deflate::Deflate PROPERTIES |
| 107 |
IMPORTED_LOCATION_DEBUG "${Deflate_LIBRARY_DEBUG}") |
| 108 |
endif() |
| 109 |
|
| 110 |
if(NOT Deflate_LIBRARY_RELEASE AND NOT Deflate_LIBRARY_DEBUG) |
| 111 |
set_target_properties(Deflate::Deflate PROPERTIES |
| 112 |
IMPORTED_LOCATION "${Deflate_LIBRARY}") |
| 113 |
endif() |
| 114 |
endif() |
| 115 |
endif() |