2016-02-11 15:49:39 +01:00
|
|
|
# - Try to find jemalloc
|
|
|
|
# Once done this will define
|
|
|
|
# JEMALLOC_FOUND - System has jemalloc
|
|
|
|
# JEMALLOC_INCLUDE_DIRS - The jemalloc include directories
|
|
|
|
# JEMALLOC_LIBRARIES - The libraries needed to use jemalloc
|
|
|
|
|
2016-02-15 01:12:07 +01:00
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
pkg_check_modules(PC_JEMALLOC QUIET jemalloc)
|
2016-02-11 15:49:39 +01:00
|
|
|
|
2016-02-15 01:12:07 +01:00
|
|
|
find_path(JEMALLOC_INCLUDE_DIR
|
|
|
|
NAMES jemalloc/jemalloc.h
|
2016-03-13 16:41:21 +01:00
|
|
|
HINTS ${PC_JEMALLOC_INCLUDE_DIRS}
|
2016-02-15 01:12:07 +01:00
|
|
|
)
|
|
|
|
find_library(JEMALLOC_LIBRARY
|
|
|
|
NAMES jemalloc
|
|
|
|
HINTS ${PC_JEMALLOC_LIBRARY_DIRS}
|
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
2016-02-11 15:49:39 +01:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
# handle the QUIETLY and REQUIRED arguments and set JEMALLOC_FOUND to TRUE
|
2016-02-15 01:12:07 +01:00
|
|
|
# if all listed variables are TRUE and the requested version matches.
|
2016-03-13 13:09:37 +01:00
|
|
|
find_package_handle_standard_args(Jemalloc REQUIRED_VARS
|
2016-02-15 01:12:07 +01:00
|
|
|
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()
|
2016-02-11 15:49:39 +01:00
|
|
|
|
|
|
|
mark_as_advanced(JEMALLOC_INCLUDE_DIR JEMALLOC_LIBRARY)
|