aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt47
1 files changed, 43 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8af4ef69e..f2b553d92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,21 @@ option(BOOST_IGNORE_SYSTEM_PATHS "Ignore boost system paths for local boost inst
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
enable_testing()
+# Check whether we're on a 32-bit or 64-bit system
+if(CMAKE_SIZEOF_VOID_P EQUAL "8")
+ set(DEFAULT_BUILD_64 ON)
+else()
+ set(DEFAULT_BUILD_64 OFF)
+endif()
+option(BUILD_64 "Build for 64-bit? 'OFF' builds for 32-bit." ${DEFAULT_BUILD_64})
+
+if(BUILD_64)
+ set(ARCH_WIDTH "64")
+else()
+ set(ARCH_WIDTH "32")
+endif()
+message(STATUS "Building for a ${ARCH_WIDTH}-bit system")
+
# Check if we're on FreeBSD so we can exclude the local miniupnpc (it should be installed from ports instead)
# CMAKE_SYSTEM_NAME checks are commonly known, but specifically taken from libsdl's CMakeLists
if(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
@@ -96,16 +111,16 @@ endif()
option(STATIC "Link libraries statically" ${DEFAULT_STATIC})
if(MINGW)
- get_filename_component(msys2_install_path "[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MSYS2 64bit;InstallLocation]" ABSOLUTE)
- set(CMAKE_INCLUDE_PATH "${msys2_install_path}/mingw64/include")
+ get_filename_component(msys2_install_path "[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MSYS2 ${ARCH_WIDTH}bit;InstallLocation]" ABSOLUTE)
+ set(CMAKE_INCLUDE_PATH "${msys2_install_path}/mingw${ARCH_WIDTH}/include")
# This is necessary because otherwise CMake will make Boost libraries -lfoo
# rather than a full path. Unfortunately, this makes the shared libraries get
# linked due to a bug in CMake which misses putting -static flags around the
# -lfoo arguments.
list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_DIRECTORIES
- "${msys2_install_path}/mingw64/lib")
+ "${msys2_install_path}/mingw${ARCH_WIDTH}/lib")
list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES
- "${msys2_install_path}/mingw64/lib")
+ "${msys2_install_path}/mingw${ARCH_WIDTH}/lib")
endif()
if(STATIC)
@@ -116,6 +131,27 @@ if(STATIC)
endif()
endif()
+# default database:
+# should be lmdb for testing, memory for production still
+# set(DATABASE memory)
+set(DATABASE lmdb)
+
+if (DEFINED ENV{DATABASE})
+ set(DATABASE $ENV{DATABASE})
+ message(STATUS "DATABASE set: ${DATABASE}")
+else()
+ message(STATUS "Could not find DATABASE in env (not required unless you want to change database type from default: ${DATABASE})")
+endif()
+if (DATABASE STREQUAL "lmdb")
+ set(BLOCKCHAIN_DB DB_LMDB)
+elseif (DATABASE STREQUAL "memory")
+ set(BLOCKCHAIN_DB DB_MEMORY)
+else()
+ die("Invalid database type: ${DATABASE}")
+endif()
+
+add_definitions("-DBLOCKCHAIN_DB=${BLOCKCHAIN_DB}")
+
if (UNIX AND NOT APPLE)
# Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail
find_package(Threads)
@@ -138,6 +174,9 @@ link_directories(${UNBOUND_LIBRARY_DIRS})
# Final setup for rapidjson
include_directories(external/rapidjson)
+# Final setup for liblmdb
+include_directories(${LMDB_INCLUDE})
+
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__")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")