From caae3c4757389fd50dba78d3be86f6775b1f9ce0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 13 Oct 2017 15:10:29 +0800 Subject: [PATCH] cmake: fix gperftools version detection there is chance that its "patch" version is empty. in that case, do not include it in its version string. otherwise, we will have something like: Found gperftools: GPERFTOOLS_TCMALLOC_LIBRARY;GPERFTOOLS_TCMALLOC_MINIMAL_LIBRARY;GPERFTOOLS_PROFILER_LIBRARY (found version "2.4.#define TC_VERSION_PATCH """) when running cmake Signed-off-by: Kefu Chai --- cmake/modules/Findgperftools.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/modules/Findgperftools.cmake b/cmake/modules/Findgperftools.cmake index a06e4aac7c5..3d9b7e98c24 100644 --- a/cmake/modules/Findgperftools.cmake +++ b/cmake/modules/Findgperftools.cmake @@ -21,12 +21,14 @@ if(Tcmalloc_INCLUDE_DIR AND EXISTS "${Tcmalloc_INCLUDE_DIR}/gperftools/tcmalloc. foreach(ver "MAJOR" "MINOR" "PATCH") file(STRINGS "${Tcmalloc_INCLUDE_DIR}/gperftools/tcmalloc.h" TC_VER_${ver}_LINE REGEX "^#define[ \t]+TC_VERSION_${ver}[ \t]+[^ \t]+$") - string(REGEX REPLACE "^#define[ \t]+TC_VERSION_${ver}[ \t]+(\".)?([0-9]+)\"?$" + string(REGEX REPLACE "^#define[ \t]+TC_VERSION_${ver}[ \t]+(\".)?([0-9]*)\"?$" "\\2" TCMALLOC_VERSION_${ver} "${TC_VER_${ver}_LINE}") unset(TC_VER_${ver}_LINE) endforeach() - set(TCMALLOC_VERSION_STRING - "${TCMALLOC_VERSION_MAJOR}.${TCMALLOC_VERSION_MINOR}.${TCMALLOC_VERSION_PATCH}") + set(TCMALLOC_VERSION_STRING "${TCMALLOC_VERSION_MAJOR}.${TCMALLOC_VERSION_MINOR}") + if(NOT TCMALLOC_VERSION_PATCH STREQUAL "") + set(TCMALLOC_VERSION_STRING "${TCMALLOC_VERSION_STRING}.${TCMALLOC_VERSION_PATCH}") + endif() endif() foreach(component tcmalloc tcmalloc_minimal profiler) -- 2.39.5