-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindJemalloc.cmake
58 lines (50 loc) · 2.05 KB
/
FindJemalloc.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
# from https://github.com/COMBINE-lab/salmon/blob/master/cmake/Modules/FindJemalloc.cmake
# From: https://raw.githubusercontent.com/STEllAR-GROUP/hpx/master/cmake/FindJemalloc.cmake
# Copyright (c) 2014 Thomas Heller
# Copyright (c) 2007-2012 Hartmut Kaiser
# Copyright (c) 2010-2011 Matt Anderson
# Copyright (c) 2011 Bryce Lelbach
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
find_package(PkgConfig)
pkg_check_modules(PC_JEMALLOC QUIET libjemalloc)
unset(JEMALLOC_INCLUDE_DIR CACHE)
find_path(JEMALLOC_INCLUDE_DIR jemalloc/jemalloc.h
HINTS
${JEMALLOC_ROOT} ENV JEMALLOC_ROOT
${PC_JEMALLOC_MINIMAL_INCLUDEDIR}
${PC_JEMALLOC_MINIMAL_INCLUDE_DIRS}
${PC_JEMALLOC_INCLUDEDIR}
${PC_JEMALLOC_INCLUDE_DIRS}
~/.linuxbrew/
PATH_SUFFIXES include)
unset(JEMALLOC_LIBRARY CACHE)
find_library(JEMALLOC_LIBRARY NAMES jemalloc libjemalloc
HINTS
${JEMALLOC_ROOT} ENV JEMALLOC_ROOT
${PC_JEMALLOC_MINIMAL_LIBDIR}
${PC_JEMALLOC_MINIMAL_LIBRARY_DIRS}
${PC_JEMALLOC_LIBDIR}
${PC_JEMALLOC_LIBRARY_DIRS}
~/.linuxbrew/
PATH_SUFFIXES lib lib64)
if(JEMALLOC_INCLUDE_DIR)
set(_version_regex "^#define[ \t]+JEMALLOC_VERSION[ \t]+\"([^\"]+)\".*")
file(STRINGS "${JEMALLOC_INCLUDE_DIR}/jemalloc/jemalloc.h"
JEMALLOC_VERSION REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1"
JEMALLOC_VERSION "${JEMALLOC_VERSION}")
unset(_version_regex)
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set JEMALLOC_FOUND to TRUE
# if all listed variables are TRUE and the requested version matches.
find_package_handle_standard_args(Jemalloc REQUIRED_VARS
JEMALLOC_LIBRARY JEMALLOC_INCLUDE_DIR
VERSION_VAR JEMALLOC_VERSION)
if(JEMALLOC_FOUND)
set(JEMALLOC_LIBRARIES ${JEMALLOC_LIBRARY})
set(JEMALLOC_INCLUDE_DIRS ${JEMALLOC_INCLUDE_DIR})
endif()
mark_as_advanced(JEMALLOC_INCLUDE_DIR JEMALLOC_LIBRARY)