cmake: cleanup Findtcmalloc.cmake

use find_package_handle_standard_args() and remove unused bits.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2016-07-22 01:13:48 +08:00
parent 3170f16e86
commit 3f6fd585f8

View File

@ -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)