From 3f6fd585f8afa93d4462881232ebf7c206b78259 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 22 Jul 2016 01:13:48 +0800 Subject: [PATCH] cmake: cleanup Findtcmalloc.cmake use find_package_handle_standard_args() and remove unused bits. Signed-off-by: Kefu Chai --- cmake/modules/Findtcmalloc.cmake | 45 +++++++++----------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/cmake/modules/Findtcmalloc.cmake b/cmake/modules/Findtcmalloc.cmake index d9b3a456f5c..9b4cf1a8070 100644 --- a/cmake/modules/Findtcmalloc.cmake +++ b/cmake/modules/Findtcmalloc.cmake @@ -5,43 +5,24 @@ # Tcmalloc_LIBRARIES - List of libraries when using Tcmalloc. # Tcmalloc_FOUND - True if Tcmalloc found. -find_path(Tcmalloc_INCLUDE_DIR google/tcmalloc.h NO_DEFAULT_PATH PATHS - ${HT_DEPENDENCY_INCLUDE_DIR} +find_path(Tcmalloc_INCLUDE_DIR google/tcmalloc.h PATHS /usr/include /opt/local/include - /usr/local/include -) + /usr/local/include) -if (USE_TCMALLOC) - set(Tcmalloc_NAMES tcmalloc) -else () - set(Tcmalloc_NAMES tcmalloc_minimal tcmalloc) -endif () +find_library(Tcmalloc_LIBRARY + NAMES tcmalloc_minimal tcmalloc + PATHS /lib /usr/lib /usr/local/lib /opt/local/lib) -find_library(Tcmalloc_LIBRARY NO_DEFAULT_PATH - NAMES ${Tcmalloc_NAMES} - PATHS ${HT_DEPENDENCY_LIB_DIR} /lib /usr/lib /usr/local/lib /opt/local/lib -) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Tcmalloc + FOUND_VAR Tcmalloc_FOUND + REQUIRED_VARS Tcmalloc_INCLUDE_DIR Tcmalloc_LIBRARY) -if (Tcmalloc_INCLUDE_DIR AND Tcmalloc_LIBRARY) - set(Tcmalloc_FOUND TRUE) - set( Tcmalloc_LIBRARIES ${Tcmalloc_LIBRARY} ) -else () - set(Tcmalloc_FOUND FALSE) - set( Tcmalloc_LIBRARIES ) -endif () - -if (Tcmalloc_FOUND) - message(STATUS "Found Tcmalloc: ${Tcmalloc_LIBRARY}") -else () - message(STATUS "Not Found Tcmalloc: ${Tcmalloc_LIBRARY}") - if (Tcmalloc_FIND_REQUIRED) - message(STATUS "Looked for Tcmalloc libraries named ${Tcmalloc_NAMES}.") - message(FATAL_ERROR "Could NOT find Tcmalloc library") - endif () -endif () +if(Tcmalloc_FOUND) + set(Tcmalloc_LIBRARIES ${Tcmalloc_LIBRARY}) +endif() mark_as_advanced( Tcmalloc_LIBRARY - Tcmalloc_INCLUDE_DIR - ) + Tcmalloc_INCLUDE_DIR)