From: Kefu Chai Date: Fri, 13 Oct 2017 07:10:29 +0000 (+0800) Subject: cmake: fix gperftools version detection X-Git-Tag: v13.0.1~581^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=caae3c4757389fd50dba78d3be86f6775b1f9ce0;p=ceph.git 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 --- diff --git a/cmake/modules/Findgperftools.cmake b/cmake/modules/Findgperftools.cmake index a06e4aac7c583..3d9b7e98c243c 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)