Fix T54287: memory not freed after rendering on Linux.
[blender.git] / build_files / cmake / Modules / FindJeMalloc.cmake
index 506892b34ba2b2e844a0bf58513546821ef3e0ed..0abe103cd2ea08af4af5810d9051aeb6964645b1 100644 (file)
@@ -53,6 +53,15 @@ FIND_LIBRARY(JEMALLOC_LIBRARY
     lib64 lib
   )
 
+if(JEMALLOC_INCLUDE_DIR)
+  SET(_version_regex "^#define[ \t]+JEMALLOC_VERSION[ \t]+\"([^\"]+)\".*")
+  file(STRINGS "${JEMALLOC_INCLUDE_DIR}/jemalloc.h"
+    JEMALLOC_VERSION REGEX "${_version_regex}")
+  string(REGEX REPLACE "${_version_regex}" "\\1"
+    JEMALLOC_VERSION "${JEMALLOC_VERSION}")
+  unset(_version_regex)
+endif()
+
 # handle the QUIETLY and REQUIRED arguments and set JEMALLOC_FOUND to TRUE if
 # all listed variables are TRUE
 INCLUDE(FindPackageHandleStandardArgs)