2 # This file is open source software, licensed to you under the terms
3 # of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 # distributed with this work for additional information regarding copyright
5 # ownership. You may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
20 # Copyright (C) 2018 Scylladb, Ltd.
23 find_package (PkgConfig REQUIRED)
25 pkg_search_module (lz4_PC liblz4)
27 find_library (lz4_LIBRARY
31 ${lz4_PC_LIBRARY_DIRS})
33 find_path (lz4_INCLUDE_DIR
37 ${lz4_PC_INCLUDEDIRS})
43 include (FindPackageHandleStandardArgs)
45 find_package_handle_standard_args (lz4
49 VERSION_VAR lz4_PC_VERSION)
51 set (lz4_LIBRARIES ${lz4_LIBRARY})
52 set (lz4_INCLUDE_DIRS ${lz4_INCLUDE_DIR})
55 set (CMAKE_REQUIRED_LIBRARIES ${lz4_LIBRARY})
56 include (CheckSymbolExists)
58 check_symbol_exists (LZ4_compress_default
59 ${lz4_INCLUDE_DIR}/lz4.h
60 lz4_HAVE_COMPRESS_DEFAULT)
63 if (lz4_FOUND AND NOT (TARGET lz4::lz4))
64 add_library (lz4::lz4 UNKNOWN IMPORTED)
66 set_target_properties (lz4::lz4
68 IMPORTED_LOCATION ${lz4_LIBRARY}
69 INTERFACE_INCLUDE_DIRECTORIES ${lz4_INCLUDE_DIRS})