generated from zethon/CCCBTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindxxHash.cmake
66 lines (58 loc) · 2.14 KB
/
FindxxHash.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.
# All rights reserved.
#
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.
#.rst:
# FindxxHash
# -----------
#
# Find the xxHash library header and define variables.
#
# Imported Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines :prop_tgt:`IMPORTED` target ``xxHash::xxHash``,
# if xxHash has been found
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables:
#
# ::
#
# xxHash_FOUND - True if xxHash is found.
# xxHash_INCLUDE_DIRS - Where to find xxhash.h
#
# ::
#
# xxHash_VERSION - The version of xxHash found (x.y.z)
# xxHash_VERSION_MAJOR - The major version of xxHash
# xxHash_VERSION_MINOR - The minor version of xxHash
# xxHash_VERSION_PATCH - The patch version of xxHash
find_path(xxHash_INCLUDE_DIR NAME xxhash.h PATH_SUFFIXES include)
find_library(xxHash_LIBRARY NAMES xxhash xxHash PATH_SUFFIXES lib)
mark_as_advanced(xxHash_INCLUDE_DIR)
if(xxHash_INCLUDE_DIR AND EXISTS "${xxHash_INCLUDE_DIR}/xxhash.h")
file(STRINGS "${xxHash_INCLUDE_DIR}/xxhash.h" XXHASH_H REGEX "^#define XXH_VERSION_[A-Z]+[ ]+[0-9]+$")
string(REGEX REPLACE ".+XXH_VERSION_MAJOR[ ]+([0-9]+).*$" "\\1" xxHash_VERSION_MAJOR "${XXHASH_H}")
string(REGEX REPLACE ".+XXH_VERSION_MINOR[ ]+([0-9]+).*$" "\\1" xxHash_VERSION_MINOR "${XXHASH_H}")
string(REGEX REPLACE ".+XXH_VERSION_RELEASE[ ]+([0-9]+).*$" "\\1" xxHash_VERSION_PATCH "${XXHASH_H}")
set(xxHash_VERSION "${xxHash_VERSION_MAJOR}.${xxHash_VERSION_MINOR}.${xxHash_VERSION_PATCH}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(xxHash
REQUIRED_VARS xxHash_LIBRARY xxHash_INCLUDE_DIR VERSION_VAR xxHash_VERSION)
if(xxHash_FOUND)
set(xxHash_INCLUDE_DIRS "${xxHash_INCLUDE_DIR}")
if(NOT xxHash_LIBRARIES)
set(xxHash_LIBRARIES ${xxHash_LIBRARY})
endif()
if(NOT TARGET xxHash::xxHash)
add_library(xxHash::xxHash UNKNOWN IMPORTED)
set_target_properties(xxHash::xxHash PROPERTIES
IMPORTED_LOCATION "${xxHash_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${xxHash_INCLUDE_DIRS}")
endif()
endif()