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)