Add separate cmake files for GMP and Tcmalloc

This commit is contained in:
Soonho Kong 2013-07-18 17:52:56 -07:00 committed by Leonardo de Moura
parent 4e3dc83621
commit a169837a3e
4 changed files with 83 additions and 0 deletions

View file

@ -23,6 +23,13 @@ Instructions for RELEASE build
cmake -DCMAKE_BUILD_TYPE=RELEASE ../../src
make
Instructions for installing gperftools on Ubuntu
sudo add-apt-repository ppa:agent-8131/ppa
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install libgoogle-perftools-dev
Instructions for installing gcc-4.8 (C++11 compatible) on Ubuntu
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y

View file

@ -0,0 +1,37 @@
/** -*- C++ -*-
* Copyright (C) 2009 Luke Lu (llu@hypertable.org)
*
* This file is part of Hypertable.
*
* Hypertable is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* Hypertable is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Hypertable. If not, see <http://www.gnu.org/licenses/>
*/
#include <stdio.h>
#include <string.h>
#include <google/tcmalloc.h>
int main() {
int major, minor;
const char *patch;
const char *version = tc_version(&major, &minor, &patch);
if (major != TC_VERSION_MAJOR || minor != TC_VERSION_MINOR ||
strcmp(patch, TC_VERSION_PATCH)) {
fprintf(stderr, "Tcmalloc header/library mismatch:\n "
"header: %s\nlibrary: %s\n", TC_VERSION_STRING, version);
return 1;
}
printf("%d.%d%s", major, minor, patch);
return 0;
}

13
src/cmake/FindGMP.cmake Normal file
View file

@ -0,0 +1,13 @@
if (GMP_INCLUDE_DIR AND GMP_LIBRARIES)
# Already in cache, be silent
set(GMP_FIND_QUIETLY TRUE)
endif (GMP_INCLUDE_DIR AND GMP_LIBRARIES)
find_path(GMP_INCLUDE_DIR NAMES gmp.h )
find_library(GMP_LIBRARIES NAMES gmp libgmp REQUIRED)
#find_library(GMPXX_LIBRARIES NAMES gmpxx libgmpxx )
#MESSAGE(STATUS "GMP: " ${GMP_LIBRARIES}) # " " ${GMPXX_LIBRARIES} )
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG GMP_INCLUDE_DIR GMP_LIBRARIES)
mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES)

View file

@ -0,0 +1,26 @@
if (TCMALLOC_INCLUDE_DIR AND TCMALLOC_LIBRARIES)
# Already in cache, be silent
set(TCMALLOC_FIND_QUIETLY TRUE)
endif (TCMALLOC_INCLUDE_DIR AND TCMALLOC_LIBRARIES)
find_path(TCMALLOC_INCLUDE_DIR NAMES google/tcmalloc.h)
find_library(TCMALLOC_LIBRARIES NAMES tcmalloc)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCMALLOC DEFAULT_MSG TCMALLOC_INCLUDE_DIR TCMALLOC_LIBRARIES)
# Print out version number
if (TCMALLOC_FOUND)
try_run(TC_CHECK TC_CHECK_BUILD
${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
${LEAN_SOURCE_DIR}/cmake/CheckTcmalloc.cc
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${TCMALLOC_INCLUDE_DIR}
-DLINK_LIBRARIES=${TCMALLOC_LIBRARIES}
RUN_OUTPUT_VARIABLE TC_TRY_OUT)
message("-- Found TCMALLOC: version ${TC_TRY_OUT}")
else ()
message("*** WARNING: failed to find tcmalloc")
message("*** The (optional) tcmalloc library is available at: https://code.google.com/p/gperftools")
endif ()
mark_as_advanced(TCMALLOC_INCLUDE_DIR TCMALLOC_LIBRARIES)