Range iterator starts with keys found in ram (for the unsorted blobs).
[eblob.git] / CMakeLists.txt
blobc5309d1fd2672c9b345fd8dcc67b5e248e2bd8e8
1 cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
2 cmake_policy (VERSION 2.6.0)
4 set(CMAKE_SKIP_RPATH FALSE)
5 set(CMAKE_SKIP_BUILD_RPATH  FALSE)
7 project (eblob)
8 FILE (READ "${CMAKE_CURRENT_SOURCE_DIR}/debian/changelog" DEBCHANGELOG)
10 string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" DEBFULLVERSION "${DEBCHANGELOG}")
11 STRING (REGEX MATCH "([0-9]+\\.[0-9]+)" EBLOB_VERSION_ABI "${DEBFULLVERSION}")
12 STRING (REGEX MATCH "([0-9]+$)" EBLOB_VERSION_MINOR "${DEBFULLVERSION}")
14 set(EBLOB_VERSION "${EBLOB_VERSION_ABI}.${EBLOB_VERSION_MINOR}")
16 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
18 option(WITH_ASSERTS "Enable asserts" OFF)
19 option(WITH_PYTHON "Build python bindings" ON)
20 option(WITH_EXAMPLES "Build examples" ON)
21 option(WITH_SNAPPY "Enable Snappy support" ON)
23 include(CheckAtomic)
24 include(TestBigEndian)
26 include_directories(${CMAKE_BINARY_DIR}/include/)
28 # Turn off aserts
29 if(!WITH_ASSERTS)
30     add_definitions(-DNDEBUG)
31 endif()
32 message(STATUS "Asserts are: ${WITH_ASSERTS}")
34 # Test endianess
35 test_big_endian(HAVE_BIG_ENDIAN)
36 if(HAVE_BIG_ENDIAN)
37     add_definitions(-DBYTEORDER=4321)
38     add_definitions(-DWORDS_BIGENDIAN=1)
39 else()
40     add_definitions(-DBYTEORDER=1234)
41 endif()
43 if (UNIX OR MINGW)
44     #
45     # Strict Aliasing notes:
46     #   Currently there are couple of memory aliases represented by char** and
47     #     void** casts in blob.c and mobjects.c
48     #   GCC prints warnings if compiling with -fstrict-aliasing
49     #   One can increase verbosity by setting -Wstrict-aliasing=2
50     #
51     # Useful warning options not implied by -Wall and -Wextra:
52     #   -Wredundant-decls
53     #   -Wmissing-declarations
54     #   -Wstrict-overflow=4
55     #
56     add_definitions(-Wall -Wextra -fstack-protector-all -fno-strict-aliasing)
57 endif()
58 if (${CMAKE_SYSTEM_NAME} MATCHES BSD)
59     add_definitions(-D__BSD_VISIBLE=1)
60 endif()
62 # Check for threads
63 if (UNIX AND BSD)
64     set(CMAKE_THREAD_LIBS -pthread)
65     set(CMAKE_USE_PTHREADS ON)
66     set(CMAKE_EXE_LINKER_FLAGS -pthread)
67 endif()
69 set(CMAKE_THREAD_PREFER_PTHREAD ON)
70 find_package(Threads REQUIRED)
71 include(CheckThreadSpinlock)
73 # Check for boost
74 #set(Boost_USE_STATIC_LIBS ON)
75 #set(Boost_USE_STLPORT ON)
76 find_package(Boost REQUIRED COMPONENTS iostreams thread system regex python)
77 message(STATUS "Boost information:")
78 message(STATUS "  Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
79 message(STATUS "  Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
80 message(STATUS "  Boost_LIBRARIES: ${Boost_LIBRARIES}")
81 include_directories(${Boost_INCLUDE_DIRS})
82 link_directories(${Boost_LIBRARY_DIRS})
84 # Check for snappy - unusual dependency, it doesn't use pkgconfig
85 if (WITH_SNAPPY)
86     find_package(SNAPPY REQUIRED)
87     include_directories(${SNAPPY_INCLUDE_DIR})
88     add_definitions(-DHAVE_SNAPPY_SUPPORT)
89 endif()
91 # Check for python
92 if(WITH_PYTHON)
93     find_package(PythonLibs REQUIRED)
94     message(STATUS "Python includes are situated in (${PYTHON_INCLUDE_PATH}, ${PYTHON_INCLUDE_DIRS})")
95     include_directories(${PYTHON_INCLUDE_PATH})
96     include_directories(${PYTHON_INCLUDE_DIRS})
97 endif()
99 # Check for posix_fadvise
100 include(CheckSymbolExists)
101 check_symbol_exists(posix_fadvise "fcntl.h" HAVE_POSIX_FADVISE)
102 if (HAVE_POSIX_FADVISE)
103     add_definitions(-DHAVE_POSIX_FADVISE)
104 endif()
106 # Collect all libraries together
107 set(EBLOB_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${SNAPPY_LIBRARIES})
108 set(EBLOB_CPP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${Boost_IOSTREAMS_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY})
109 set(EBLOB_PYTHON_LIBRARIES ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
111 # Build parts
112 add_subdirectory(library)
113 if (WITH_EXAMPLES)
114     add_subdirectory(example)
115 endif()
116 add_subdirectory(bindings)
118 install(FILES
119     include/eblob/eblob.hpp
120     include/eblob/blob.h
121     DESTINATION include/eblob/
122     )