From b89ba58c9e52695daed33c34c7a8eea5dcff660b Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Fri, 24 Dec 2021 10:49:56 +0300 Subject: [PATCH] Tweak berkeley db detection --- CMakeLists.txt | 27 ++++++++++++++++++--------- src/CMakeLists.txt | 38 ++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e6bc57..68e5e30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,15 @@ endif() # Set default library path for berkeley db if (NOT BerkeleyDB_LIBS) set(BerkeleyDB_LIBS ${BerkeleyDB_ROOT}/lib) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +# Workaround for linux distributions +set(BerkeleyDB_LIBS ${BerkeleyDB_LIBS}/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) +endif() +endif() + +# Set default library name for berkeley db +if (NOT BerkeleyDB_LIB_name) +set(BerkeleyDB_LIB_name libdb_cxx) endif() set(generic_sources @@ -194,16 +203,16 @@ if (NOT WIN32 AND NOT APPLE) endif() # Try various libdb library file extensions -if (EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.a) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.a) -elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.so) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.so) -elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.dylib) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.dylib) -elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.dll) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.dll) +if (EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.a) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.a) +elseif(EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.so) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.so) +elseif(EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.dylib) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.dylib) +elseif(EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.lib) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.lib) else() - message(FATAL_ERROR "Unable to find libdb_cxx library in ${BerkeleyDB_LIBS} directory. Try to specify either library path via BerkeleyDB_LIBS or berkeley db root path via BerkeleyDB_ROOT variable.") + message(FATAL_ERROR "Unable to find ${BerkeleyDB_LIB_name} library in ${BerkeleyDB_LIBS} directory. Try to specify either library path via BerkeleyDB_LIBS or berkeley db root path via BerkeleyDB_ROOT variable. You can also use BerkeleyDB_LIB_name variable to provide alternative file name search for.") endif() list(APPEND ALL_DEFINITIONS QT_GUI USE_QRCODE USE_IPV6) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05a7d03..2fd5f7d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,6 +53,15 @@ endif() # Set default library path for berkeley db if (NOT BerkeleyDB_LIBS) set(BerkeleyDB_LIBS ${BerkeleyDB_ROOT}/lib) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +# Workaround for linux distributions +set(BerkeleyDB_LIBS ${BerkeleyDB_LIBS}/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) +endif() +endif() + +# Set default library name for berkeley db +if (NOT BerkeleyDB_LIB_name) +set(BerkeleyDB_LIB_name libdb_cxx) endif() set(generic_sources @@ -107,27 +116,16 @@ if (NOT WIN32 AND NOT APPLE) endif() # Try various libdb library file extensions -if (EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.a) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.a) -elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.so) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.so) -elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.dylib) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.dylib) -elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.dll) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.dll) +if (EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.a) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.a) +elseif(EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.so) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.so) +elseif(EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.dylib) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.dylib) +elseif(EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.lib) + list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.lib) else() - set(BerkeleyDB_LIBS ${BerkeleyDB_ROOT}/lib/x86_64-linux-gnu) - if (EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.a) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.a) - elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.so) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.so) - elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.dylib) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.dylib) - elseif(EXISTS ${BerkeleyDB_LIBS}/libdb_cxx.dll) - list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/libdb_cxx.dll) - else() - message(FATAL_ERROR "Unable to find libdb_cxx library in ${BerkeleyDB_LIBS} directory. Try to specify either library path via BerkeleyDB_LIBS or berkeley db root path via BerkeleyDB_ROOT variable.") - endif() + message(FATAL_ERROR "Unable to find ${BerkeleyDB_LIB_name} library in ${BerkeleyDB_LIBS} directory. Try to specify either library path via BerkeleyDB_LIBS or berkeley db root path via BerkeleyDB_ROOT variable. You can also use BerkeleyDB_LIB_name variable to provide alternative file name search for.") endif() if(USE_LEVELDB) -- 1.7.1