]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cmake: fix gperftools version detection
authorKefu Chai <kchai@redhat.com>
Fri, 13 Oct 2017 07:10:29 +0000 (15:10 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Oct 2017 07:11:09 +0000 (15:11 +0800)
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 <kchai@redhat.com>
cmake/modules/Findgperftools.cmake

index a06e4aac7c583953b677325c0c47933b5ac84d55..3d9b7e98c243c5d95e3c4d9f01c3752eaef81c9d 100644 (file)
@@ -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)