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)
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)
24 include(TestBigEndian)
26 include_directories(${CMAKE_BINARY_DIR}/include/)
30 add_definitions(-DNDEBUG)
32 message(STATUS "Asserts are: ${WITH_ASSERTS}")
35 test_big_endian(HAVE_BIG_ENDIAN)
37 add_definitions(-DBYTEORDER=4321)
38 add_definitions(-DWORDS_BIGENDIAN=1)
40 add_definitions(-DBYTEORDER=1234)
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
51 # Useful warning options not implied by -Wall and -Wextra:
53 # -Wmissing-declarations
56 add_definitions(-Wall -Wextra -fstack-protector-all -fno-strict-aliasing)
58 if (${CMAKE_SYSTEM_NAME} MATCHES BSD)
59 add_definitions(-D__BSD_VISIBLE=1)
64 set(CMAKE_THREAD_LIBS -pthread)
65 set(CMAKE_USE_PTHREADS ON)
66 set(CMAKE_EXE_LINKER_FLAGS -pthread)
69 set(CMAKE_THREAD_PREFER_PTHREAD ON)
70 find_package(Threads REQUIRED)
71 include(CheckThreadSpinlock)
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
86 find_package(SNAPPY REQUIRED)
87 include_directories(${SNAPPY_INCLUDE_DIR})
88 add_definitions(-DHAVE_SNAPPY_SUPPORT)
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})
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)
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})
112 add_subdirectory(library)
114 add_subdirectory(example)
116 add_subdirectory(bindings)
119 include/eblob/eblob.hpp
121 DESTINATION include/eblob/