| 1 |
# |
| 2 |
# Copyright by The HDF Group. |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# This file is part of HDF5. The full HDF5 copyright notice, including |
| 6 |
# terms governing use, modification, and redistribution, is contained in |
| 7 |
# the COPYING file, which can be found at the root of the source code |
| 8 |
# distribution tree, or in https://www.hdfgroup.org/licenses. |
| 9 |
# If you do not have access to either file, you may request a copy from |
| 10 |
# [email protected]. |
| 11 |
# |
| 12 |
######################################################################### |
| 13 |
|
| 14 |
# - Derived from the FindTiff.cmake and FindJPEG.cmake that is included with cmake |
| 15 |
# FindSZIP |
| 16 |
|
| 17 |
# Find the native SZIP includes and library |
| 18 |
|
| 19 |
# Imported targets |
| 20 |
################## |
| 21 |
|
| 22 |
# This module defines the following :prop_tgt:`IMPORTED` targets: |
| 23 |
# |
| 24 |
# SZIP::SZIP |
| 25 |
# The SZIP library, if found. |
| 26 |
# |
| 27 |
# Result variables |
| 28 |
################### |
| 29 |
|
| 30 |
# This module will set the following variables in your project: |
| 31 |
|
| 32 |
# SZIP_FOUND, true if the SZIP headers and libraries were found. |
| 33 |
# SZIP_INCLUDE_DIR, the directory containing the SZIP headers. |
| 34 |
# SZIP_INCLUDE_DIRS, the directory containing the SZIP headers. |
| 35 |
# SZIP_LIBRARIES, libraries to link against to use SZIP. |
| 36 |
|
| 37 |
# Cache variables |
| 38 |
################# |
| 39 |
|
| 40 |
# The following variables may also be set: |
| 41 |
|
| 42 |
# SZIP_LIBRARY, where to find the SZIP library. |
| 43 |
# SZIP_LIBRARY_DEBUG - Debug version of SZIP library |
| 44 |
# SZIP_LIBRARY_RELEASE - Release Version of SZIP library |
| 45 |
|
| 46 |
# message (STATUS "Finding SZIP library and headers..." ) |
| 47 |
######################################################################### |
| 48 |
|
| 49 |
|
| 50 |
find_path(SZIP_INCLUDE_DIR szlib.h) |
| 51 |
|
| 52 |
set(szip_names ${SZIP_NAMES} sz szip szip-static libsz libszip libszip-static) |
| 53 |
foreach(name ${szip_names}) |
| 54 |
list (APPEND szip_names_debug "${name}d") |
| 55 |
endforeach() |
| 56 |
|
| 57 |
if(NOT SZIP_LIBRARY) |
| 58 |
find_library(SZIP_LIBRARY_RELEASE NAMES ${szip_names}) |
| 59 |
find_library(SZIP_LIBRARY_DEBUG NAMES ${szip_names_debug}) |
| 60 |
include(SelectLibraryConfigurations) |
| 61 |
select_library_configurations(SZIP) |
| 62 |
mark_as_advanced(SZIP_LIBRARY_RELEASE SZIP_LIBRARY_DEBUG) |
| 63 |
endif() |
| 64 |
unset(szip_names) |
| 65 |
unset(szip_names_debug) |
| 66 |
|
| 67 |
if(SZIP_INCLUDE_DIR AND EXISTS "${SZIP_INCLUDE_DIR}/SZconfig.h") |
| 68 |
file(STRINGS "${SZIP_INCLUDE_DIR}/SZconfig.h" szip_version_str |
| 69 |
REGEX "^#define[\t ]+SZIP_PACKAGE_VERSION[\t ]+.*") |
| 70 |
|
| 71 |
string(REGEX REPLACE "^#define[\t ]+SZIP_PACKAGE_VERSION[\t ]+([0-9]+).*" |
| 72 |
"\\1" SZIP_VERSION "${szip_version_str}") |
| 73 |
unset(szip_version_str) |
| 74 |
endif() |
| 75 |
|
| 76 |
include(FindPackageHandleStandardArgs) |
| 77 |
find_package_handle_standard_args(SZIP |
| 78 |
REQUIRED_VARS SZIP_LIBRARY SZIP_INCLUDE_DIR |
| 79 |
VERSION_VAR SZIP_VERSION) |
| 80 |
|
| 81 |
if(SZIP_FOUND) |
| 82 |
set(SZIP_LIBRARIES ${SZIP_LIBRARY}) |
| 83 |
set(SZIP_INCLUDE_DIRS "${SZIP_INCLUDE_DIR}") |
| 84 |
|
| 85 |
if(NOT TARGET SZIP::SZIP) |
| 86 |
add_library(SZIP::SZIP UNKNOWN IMPORTED) |
| 87 |
if(SZIP_INCLUDE_DIRS) |
| 88 |
set_target_properties(SZIP::SZIP PROPERTIES |
| 89 |
INTERFACE_INCLUDE_DIRECTORIES "${SZIP_INCLUDE_DIRS}") |
| 90 |
endif() |
| 91 |
if(EXISTS "${SZIP_LIBRARY}") |
| 92 |
set_target_properties(SZIP::SZIP PROPERTIES |
| 93 |
IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
| 94 |
IMPORTED_LOCATION "${SZIP_LIBRARY}") |
| 95 |
endif() |
| 96 |
if(EXISTS "${SZIP_LIBRARY_RELEASE}") |
| 97 |
set_property(TARGET SZIP::SZIP APPEND PROPERTY |
| 98 |
IMPORTED_CONFIGURATIONS RELEASE) |
| 99 |
set_target_properties(SZIP::SZIP PROPERTIES |
| 100 |
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" |
| 101 |
IMPORTED_LOCATION_RELEASE "${SZIP_LIBRARY_RELEASE}") |
| 102 |
endif() |
| 103 |
if(EXISTS "${SZIP_LIBRARY_DEBUG}") |
| 104 |
set_property(TARGET SZIP::SZIP APPEND PROPERTY |
| 105 |
IMPORTED_CONFIGURATIONS DEBUG) |
| 106 |
set_target_properties(SZIP::SZIP PROPERTIES |
| 107 |
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" |
| 108 |
IMPORTED_LOCATION_DEBUG "${SZIP_LIBRARY_DEBUG}") |
| 109 |
endif() |
| 110 |
endif() |
| 111 |
endif() |
| 112 |
|
| 113 |
mark_as_advanced(SZIP_LIBRARY SZIP_INCLUDE_DIR) |
| 114 |
|
| 115 |
# Report the results. |
| 116 |
if (NOT SZIP_FOUND) |
| 117 |
set (SZIP_DIR_MESSAGE |
| 118 |
"SZip was not found. Make sure SZIP_LIBRARY and SZIP_INCLUDE_DIR are set or set the SZIP_INSTALL environment variable." |
| 119 |
) |
| 120 |
if (NOT SZIP_FIND_QUIETLY) |
| 121 |
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") |
| 122 |
message (VERBOSE "${SZIP_DIR_MESSAGE}") |
| 123 |
endif () |
| 124 |
else () |
| 125 |
if (SZIP_FIND_REQUIRED) |
| 126 |
message (FATAL_ERROR "SZip was NOT found and is Required by this project") |
| 127 |
endif () |
| 128 |
endif () |
| 129 |
endif () |