Warning, /education/labplot/cmake/FindLZ4.cmake is written in an unsupported language. File is not indexed.
0001 #============================================================================= 0002 # Copyright (c) 2019 Harald Sitter <sitter@kde.org> 0003 # 0004 # Redistribution and use in source and binary forms, with or without 0005 # modification, are permitted provided that the following conditions 0006 # are met: 0007 # 0008 # 1. Redistributions of source code must retain the copyright 0009 # notice, this list of conditions and the following disclaimer. 0010 # 2. Redistributions in binary form must reproduce the copyright 0011 # notice, this list of conditions and the following disclaimer in the 0012 # documentation and/or other materials provided with the distribution. 0013 # 3. The name of the author may not be used to endorse or promote products 0014 # derived from this software without specific prior written permission. 0015 # 0016 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 #============================================================================= 0027 0028 find_package(PkgConfig QUIET) 0029 pkg_check_modules(PC_LZ4 lz4 QUIET) 0030 0031 find_library(LZ4_LIBRARY 0032 NAMES lz4 0033 HINTS ${PC_LZ4_LIBRARY_DIRS} 0034 ) 0035 0036 find_path(LZ4_INCLUDE_DIR 0037 NAMES lz4.h 0038 HINTS ${PC_LZ4_INCLUDE_DIRS} 0039 ) 0040 0041 set(LZ4_VERSION "${PC_LZ4_VERSION}") 0042 0043 if(NOT LZ4_VERSION) 0044 if(EXISTS "${LZ4_INCLUDE_DIR}/lz4.h") 0045 file(READ "${LZ4_INCLUDE_DIR}/lz4.h" LZ4_H_CONTENT) 0046 0047 string(REGEX MATCH "#define LZ4_VERSION_MAJOR[ ]+[0-9]+" LZ4_VERSION_MAJOR_MATCH ${LZ4_H_CONTENT}) 0048 string(REGEX MATCH "#define LZ4_VERSION_MINOR[ ]+[0-9]+" LZ4_VERSION_MINOR_MATCH ${LZ4_H_CONTENT}) 0049 string(REGEX MATCH "#define LZ4_VERSION_RELEASE[ ]+[0-9]+" LZ4_VERSION_RELEASE_MATCH ${LZ4_H_CONTENT}) 0050 0051 string(REGEX REPLACE ".*_MAJOR[ ]+(.*)" "\\1" LZ4_VERSION_MAJOR ${LZ4_VERSION_MAJOR_MATCH}) 0052 string(REGEX REPLACE ".*_MINOR[ ]+(.*)" "\\1" LZ4_VERSION_MINOR ${LZ4_VERSION_MINOR_MATCH}) 0053 string(REGEX REPLACE ".*_RELEASE[ ]+(.*)" "\\1" LZ4_VERSION_RELEASE ${LZ4_VERSION_RELEASE_MATCH}) 0054 0055 set(LZ4_VERSION "${LZ4_VERSION_MAJOR}.${LZ4_VERSION_MINOR}.${LZ4_VERSION_RELEASE}") 0056 else() 0057 set(LZ4_VERSION "0.0.0") 0058 endif() 0059 endif() 0060 0061 include(FindPackageHandleStandardArgs) 0062 find_package_handle_standard_args(LZ4 0063 REQUIRED_VARS 0064 LZ4_LIBRARY 0065 LZ4_INCLUDE_DIR 0066 VERSION_VAR 0067 LZ4_VERSION 0068 ) 0069 0070 if(LZ4_FOUND AND NOT TARGET lz4::lz4) 0071 add_library(lz4::lz4 UNKNOWN IMPORTED) 0072 set_target_properties(lz4::lz4 PROPERTIES 0073 IMPORTED_LOCATION "${LZ4_LIBRARY}" 0074 INTERFACE_COMPILE_OPTIONS "${PC_LZ4_CFLAGS}" 0075 INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}" 0076 ) 0077 endif() 0078 0079 mark_as_advanced(LZ4_LIBRARY LZ4_INCLUDE_DIR LZ4_VERSION) 0080 0081 include(FeatureSummary) 0082 set_package_properties(LZ4 PROPERTIES 0083 DESCRIPTION "Lossless compression algorithm" 0084 URL "https://lz4.github.io/lz4/" 0085 )