Tweak berkeley db detection
[novacoin.git] / CMakeLists.txt
index 3a59df9..68e5e30 100644 (file)
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.4.1)
 ##
 ## mkdir build && cd build
 ##
-## cmake -DBerkeleyDB_ROOT:STRING=/opt/homebrew/Cellar/berkeley-db@4/4.8.30 ..
+## cmake -DBerkeleyDB_ROOT:STRING=/opt/homebrew/Cellar/berkeley-db@4/4.8.30 -DUSE_LEVELDB=1 -DQt5_DIR:STRING=/opt/homebrew/Cellar/qt@5/5.15.2_1/lib/cmake/Qt5 ..
 ## cmake -DBerkeleyDB_INC:STRING=/usr/include -DBerkeleyDB_LIBS:STRING=/usr/lib/aarch64-linux-gnu -DUSE_LEVELDB=1 ..
 ##
 
@@ -38,7 +38,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
 find_package(Qt5 COMPONENTS LinguistTools Core Widgets Gui Network Qml REQUIRED)
 
 set (CMAKE_C_FLAGS "-flto -O3 -fPIC -Wno-deprecated -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2")
-set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fexceptions -frtti")
+set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -fexceptions -frtti")
 
 set(Boost_USE_STATIC_LIBS   ON)
 find_package(Boost REQUIRED COMPONENTS atomic chrono filesystem program_options system thread)
@@ -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,19 +203,19 @@ 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)
+list(APPEND ALL_DEFINITIONS QT_GUI USE_QRCODE USE_IPV6)
 
 if(USE_LEVELDB)
     # Disable useless targets