Remove duplicate compiler launcher
[novacoin.git] / src / CMakeLists.txt
index 05a7d03..a4a266b 100644 (file)
@@ -3,8 +3,8 @@ 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_INC:STRING=/usr/include -DBerkeleyDB_LIBS:STRING=/usr/lib/aarch64-linux-gnu -DUSE_LEVELDB=1 ..
+## cmake -DBerkeleyDB_ROOT:STRING=/opt/homebrew/Cellar/berkeley-db@4/4.8.30 -DUSE_LEVELDB=1 ..
+## cmake -DUSE_LEVELDB=1 ..
 ##
 
 project(novacoind VERSION 0.5.9 LANGUAGES C CXX)
@@ -21,7 +21,6 @@ endif()
 
 find_program(CCACHE_FOUND ccache)
 if(CCACHE_FOUND)
-    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
     set(CMAKE_C_COMPILER_LAUNCHER ccache)
     set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
 endif(CCACHE_FOUND)
@@ -53,6 +52,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 +115,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)
-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()
+foreach(ext a so dylib lib)
+if (EXISTS ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.${ext})
+    list(APPEND ALL_LIBRARIES ${BerkeleyDB_LIBS}/${BerkeleyDB_LIB_name}.${ext})
+    set (BDB_FOUND True)
+    break()
+endif()
+endforeach()
+
+if (NOT BDB_FOUND)
+    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)