Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Upgrade Mac and Linux LevelDB 1.12 -> 1.18-bitcoin
Browse files Browse the repository at this point in the history
  • Loading branch information
vikramrajkumar committed Nov 19, 2014
1 parent 49d5244 commit 390cc60
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,6 +14,7 @@ docs/latex
CMakeCache.txt
CMakeFiles
Makefile
!CMakeModules/*

compile_commands.json
.ycm_extra_conf.py*
Expand Down
67 changes: 46 additions & 21 deletions CMakeLists.txt
Expand Up @@ -96,27 +96,48 @@ if( WIN32 )

SET(TCL_LIBS "${TCL_LIBS}${TCL_LIB_PATH}/${TCL_LIB_NAME}g${TCL_LIB_EXT}")
SET(TCL_LIBRARY ${TCL_LIBS})
else( WIN32 )
# Apple AND Linux Options Here
find_package( ZLIB REQUIRED )

#set( LEVEL_DB_DIR "${CMAKE_SOURCE_DIR}/libraries/leveldb" )
#include( ExternalProject )
#ExternalProject_Add( LevelDB
#PREFIX "${LEVEL_DB_DIR}"
#SOURCE_DIR "${LEVEL_DB_DIR}"
#BUILD_IN_SOURCE 1
#CONFIGURE_COMMAND ""
#BUILD_COMMAND "$(MAKE)"
#INSTALL_COMMAND ""
#)
#include_directories( "${LEVEL_DB_DIR}" "${LEVEL_DB_DIR}/include" )
#add_library( leveldb STATIC IMPORTED )
#add_dependencies( leveldb LevelDB )
#set_property(TARGET leveldb PROPERTY IMPORTED_LOCATION "${LEVEL_DB_DIR}/libleveldb.a" )

set( LEVEL_DB_DIR vendor/leveldb-1.12.0 )
add_subdirectory( "${LEVEL_DB_DIR}" )

else( WIN32 ) # Apple AND Linux

set( LEVEL_DB_DIR "${CMAKE_SOURCE_DIR}/libraries/leveldb" )

file( GLOB LEVEL_DB_SOURCES
"${LEVEL_DB_DIR}/db/*.cc"
"${LEVEL_DB_DIR}/port/port_posix.cc"
"${LEVEL_DB_DIR}/helpers/memenv/memenv.cc"
"${LEVEL_DB_DIR}/table/*.cc"
"${LEVEL_DB_DIR}/util/*.cc"
)
foreach( filename ${LEVEL_DB_SOURCES} )
if( ${filename} MATCHES ".*_test.cc" OR ${filename} MATCHES ".*_bench.cc" OR ${filename} MATCHES ".*_main.cc" )
list( REMOVE_ITEM LEVEL_DB_SOURCES ${filename} )
endif()
endforeach()

add_library( leveldb ${LEVEL_DB_SOURCES} )
target_include_directories( leveldb PUBLIC "${LEVEL_DB_DIR}" "${LEVEL_DB_DIR}/include" )

find_package( Gperftools QUIET )
if( GPERFTOOLS_FOUND )
message( STATUS "Found gperftools; compiling LevelDB with TCMalloc")
else()
message( STATUS "Could not find gperftools; compiling LevelDB without TCMalloc")
endif()

add_definitions( -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT )
if( APPLE )
add_definitions( -DOS_MACOSX )
if( GPERFTOOLS_FOUND )
target_link_libraries( leveldb tcmalloc )
endif()
else() # Linux
add_definitions( -DOS_LINUX -DCYGWIN )
if( GPERFTOOLS_FOUND )
target_link_libraries( leveldb pthread tcmalloc )
else()
target_link_libraries( leveldb pthread )
endif()
endif()

find_library(READLINE_LIBRARIES NAMES readline)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
Expand All @@ -140,6 +161,10 @@ else( WIN32 )
endif ( FULL_STATIC_BUILD )
endif( APPLE )

if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp" )
endif()

if( "${CMAKE_GENERATOR}" STREQUAL "Ninja" )
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics" )
Expand Down
Empty file modified CMakeModules/FindBerkeleyDB.cmake 100755 → 100644
Empty file.
51 changes: 51 additions & 0 deletions CMakeModules/FindGperftools.cmake
@@ -0,0 +1,51 @@
# Tries to find Gperftools.
#
# Usage of this module as follows:
#
# find_package(Gperftools)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Gperftools_ROOT_DIR Set this variable to the root installation of
# Gperftools if the module has problems finding
# the proper installation path.
#
# Variables defined by this module:
#
# GPERFTOOLS_FOUND System has Gperftools libs/headers
# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler)
# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers

find_library(GPERFTOOLS_TCMALLOC
NAMES tcmalloc
HINTS ${Gperftools_ROOT_DIR}/lib)

find_library(GPERFTOOLS_PROFILER
NAMES profiler
HINTS ${Gperftools_ROOT_DIR}/lib)

find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER
NAMES tcmalloc_and_profiler
HINTS ${Gperftools_ROOT_DIR}/lib)

find_path(GPERFTOOLS_INCLUDE_DIR
NAMES gperftools/heap-profiler.h
HINTS ${Gperftools_ROOT_DIR}/include)

set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Gperftools
DEFAULT_MSG
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)

mark_as_advanced(
Gperftools_ROOT_DIR
GPERFTOOLS_TCMALLOC
GPERFTOOLS_PROFILER
GPERFTOOLS_TCMALLOC_AND_PROFILER
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)

1 comment on commit 390cc60

@a415263
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you

Please sign in to comment.