summaryrefslogtreecommitdiffstats
path: root/cmake/FindSnappy.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/FindSnappy.cmake')
-rw-r--r--cmake/FindSnappy.cmake38
1 files changed, 38 insertions, 0 deletions
diff --git a/cmake/FindSnappy.cmake b/cmake/FindSnappy.cmake
new file mode 100644
index 000000000..e1c7d231b
--- /dev/null
+++ b/cmake/FindSnappy.cmake
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+
+if(TARGET Snappy::Snappy)
+ set(Snappy_FOUND TRUE)
+ return()
+endif()
+find_package(PkgConfig QUIET)
+
+if(PkgConfig_FOUND)
+ pkg_check_modules(Snappy snappy IMPORTED_TARGET)
+
+ if (TARGET PkgConfig::Snappy)
+ add_library(Snappy::Snappy INTERFACE IMPORTED)
+ target_link_libraries(Snappy::Snappy INTERFACE PkgConfig::Snappy)
+ set(Snappy_FOUND TRUE)
+ endif()
+endif()
+
+if(NOT TARGET Snappy::Snappy)
+ find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h)
+ find_library(SNAPPY_LIBRARY NAMES snappy)
+
+ if(SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR)
+ add_library(Snappy::Snappy UNKNOWN IMPORTED)
+ set_target_properties(Snappy::Snappy PROPERTIES
+ IMPORTED_LOCATION ${SNAPPY_LIBRARY}
+ INTERFACE_INCLUDE_DIRECTORIES ${SNAPPY_INCLUDE_DIR}
+ )
+ endif()
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Snappy REQUIRED_VARS
+ SNAPPY_LIBRARY
+ SNAPPY_INCLUDE_DIR
+ )
+endif()