Only compile BerkeleyDB as an option in non-static

This commit is contained in:
Thomas Winget 2015-04-07 14:27:37 -04:00
parent 94cb295db4
commit 9519526224
No known key found for this signature in database
GPG key ID: 58131A160789E630
4 changed files with 41 additions and 17 deletions

View file

@ -178,7 +178,9 @@ include_directories(external/rapidjson)
include_directories(${LMDB_INCLUDE}) include_directories(${LMDB_INCLUDE})
# Final setup for Berkeley DB # Final setup for Berkeley DB
include_directories(${BDB_INCLUDE}) if (NOT STATIC)
include_directories(${BDB_INCLUDE})
endif()
if(MSVC) if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__") add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__")

View file

@ -34,24 +34,26 @@ set(LMDB_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/liblmdb${ARCH_WIDTH}" CACHE STRING
set(LMDB_LIBRARY "lmdb" CACHE STRING "LMDB Library name") set(LMDB_LIBRARY "lmdb" CACHE STRING "LMDB Library name")
find_package(BerkeleyDB) if (NOT STATIC)
find_package(BerkeleyDB)
if(NOT BERKELEY_DB_LIBRARIES OR STATIC) if(NOT BERKELEY_DB_LIBRARIES OR STATIC)
add_subdirectory(libdb) add_subdirectory(libdb)
message(STATUS "BerkeleyDB not found, building from src tree") message(STATUS "BerkeleyDB not found, building from src tree")
set(BDB_STATIC true CACHE BOOL "BDB Static flag") set(BDB_STATIC true CACHE BOOL "BDB Static flag")
set(BDB_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libdb" CACHE STRING "BDB include path") set(BDB_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libdb" CACHE STRING "BDB include path")
set(BDB_LIBRARY "db" CACHE STRING "BDB library name") set(BDB_LIBRARY "db" CACHE STRING "BDB library name")
else()
message(STATUS "Found BerkeleyDB include (db.h) in ${BERKELEY_DB_INCLUDE_DIR}")
if(BERKELEY_DB_LIBRARIES)
message(STATUS "Found BerkeleyDB shared library")
set(BDB_STATIC false CACHE BOOL "BDB Static flag")
set(BDB_INCLUDE ${BERKELEY_DB_INCLUDE_DIR} CACHE STRING "BDB include path")
set(BDB_LIBRARY ${BERKELEY_DB_LIBRARIES} CACHE STRING "BDB library name")
set(BDB_LIBRARY_DIRS "" CACHE STRING "BDB Library dirs")
else() else()
die("Found BerkeleyDB includes, but could not find BerkeleyDB library. Please make sure you have installed libdb and libdb-dev or the equivalent") message(STATUS "Found BerkeleyDB include (db.h) in ${BERKELEY_DB_INCLUDE_DIR}")
if(BERKELEY_DB_LIBRARIES)
message(STATUS "Found BerkeleyDB shared library")
set(BDB_STATIC false CACHE BOOL "BDB Static flag")
set(BDB_INCLUDE ${BERKELEY_DB_INCLUDE_DIR} CACHE STRING "BDB include path")
set(BDB_LIBRARY ${BERKELEY_DB_LIBRARIES} CACHE STRING "BDB library name")
set(BDB_LIBRARY_DIRS "" CACHE STRING "BDB Library dirs")
else()
die("Found BerkeleyDB includes, but could not find BerkeleyDB library. Please make sure you have installed libdb and libdb-dev or the equivalent")
endif()
endif() endif()
endif() endif()

View file

@ -29,16 +29,29 @@
set(blockchain_db_sources set(blockchain_db_sources
blockchain_db.cpp blockchain_db.cpp
lmdb/db_lmdb.cpp lmdb/db_lmdb.cpp
)
if (NOT STATIC)
set(blockchain_db_sources
${blockchain_db_sources}
berkeleydb/db_bdb.cpp berkeleydb/db_bdb.cpp
) )
endif()
set(blockchain_db_headers) set(blockchain_db_headers)
set(blockchain_db_private_headers set(blockchain_db_private_headers
blockchain_db.h blockchain_db.h
lmdb/db_lmdb.h lmdb/db_lmdb.h
)
if (NOT STATIC)
set(blockchain_db_private_headers
${blockchain_db_private_headers}
berkeleydb/db_bdb.h berkeleydb/db_bdb.h
) )
endif()
bitmonero_private_headers(blockchain_db bitmonero_private_headers(blockchain_db
${crypto_private_headers}) ${crypto_private_headers})

View file

@ -46,7 +46,9 @@ using namespace epee;
#include "cryptonote_core/checkpoints_create.h" #include "cryptonote_core/checkpoints_create.h"
#include "blockchain_db/blockchain_db.h" #include "blockchain_db/blockchain_db.h"
#include "blockchain_db/lmdb/db_lmdb.h" #include "blockchain_db/lmdb/db_lmdb.h"
#ifndef STATICLIB
#include "blockchain_db/berkeleydb/db_bdb.h" #include "blockchain_db/berkeleydb/db_bdb.h"
#endif
DISABLE_VS_WARNINGS(4355) DISABLE_VS_WARNINGS(4355)
@ -207,7 +209,12 @@ namespace cryptonote
} }
else if (db_type == "berkeley") else if (db_type == "berkeley")
{ {
#ifndef STATICLIB
db = new BlockchainBDB(); db = new BlockchainBDB();
#else
LOG_ERROR("BlockchainBDB not supported on STATIC builds");
return false;
#endif
} }
else else
{ {