Minor cleanups
[elliptics.git] / CMakeLists.txt
blob0a29ba4442c409dea191b8f44204ccc579c57f46
1 cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
2 cmake_policy (VERSION 2.6.0)
4 set(CMAKE_SKIP_RPATH OFF)
5 set(CMAKE_SKIP_BUILD_RPATH  OFF)
6 set(CMAKE_SKIP_INSTALL_RPATH OFF)
7 set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
9 project (elliptics)
10 FILE (READ "${CMAKE_CURRENT_SOURCE_DIR}/debian/changelog" DEBCHANGELOG)
12 string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)" DEBFULLVERSION "${DEBCHANGELOG}")
13 STRING (REGEX MATCH "([0-9]+\\.[0-9]+)" ELLIPTICS_VERSION_ABI "${DEBFULLVERSION}")
14 STRING (REGEX MATCH "([0-9]+\\.[0-9]+$)" ELLIPTICS_VERSION_MINOR "${DEBFULLVERSION}")
16 option(WITH_PYTHON "Build python bindings" ON)
17 option(WITH_COCAINE "Build with cocaine support" ON)
18 option(WITH_EXAMPLES "Build example applications" ON)
19 option(WITH_SMACK "Build ioserv with smack backend" ON)
20 option(WITH_LEVELDB "Build ioserv with LevelDB backend" ON)
22 set(ELLIPTICS_VERSION "${ELLIPTICS_VERSION_ABI}.${ELLIPTICS_VERSION_MINOR}")
24 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
25 include(CheckLargefile)
26 include(CheckAtomic)
27 include(CheckSendfile)
28 include(CheckIoprio)
29 include(TestBigEndian)
30 include(CheckProcStats)
31 include(CreateStdint)
33 create_stdint(${CMAKE_BINARY_DIR}/include/elliptics/typedefs.h)
34 include_directories(${CMAKE_BINARY_DIR}/include/)
36 # Set id_size
37 if (NOT ID_SIZE)
38     set(ID_SIZE 64)
39 endif()
40 add_definitions(-DCONFIG_ID_SIZE=${ID_SIZE})
42 # Test endianess
43 test_big_endian(HAVE_BIG_ENDIAN)
44 if(HAVE_BIG_ENDIAN)
45     add_definitions(-DBYTEORDER=4321)
46     add_definitions(-DWORDS_BIGENDIAN=1)
47 else()
48     add_definitions(-DBYTEORDER=1234)
49 endif()
51 if (UNIX OR MINGW)
52     add_definitions(-W -Wall -Wextra -fstack-protector-all -fno-strict-aliasing -g)
53 endif()
55 # Check for threads
56 if (UNIX AND BSD)
57     set(CMAKE_THREAD_LIBS -pthread)
58     set(CMAKE_USE_PTHREADS ON)
59     set(CMAKE_EXE_LINKER_FLAGS -pthread -Wl,--as-needed)
60 endif()
62 set(CMAKE_THREAD_PREFER_PTHREAD ON)
63 find_package(Threads REQUIRED)
65 if(WITH_COCAINE)
66     find_package(ZMQ REQUIRED)
67     include_directories(${ZMQ_INCLUDE_DIRS})
69     # Find some cocaine
70     find_package(Cocaine REQUIRED)
71     include_directories(${COCAINE_INCLUDE_DIRS})
72     add_definitions(${COCAINE_CFLAGS})
73 endif()
75 # Find eblob
76 find_package(Eblob REQUIRED)
77 include_directories(${EBLOB_INCLUDE_DIRS})
79 if(WITH_SMACK)
80     # Find smack
81     find_package(Smack REQUIRED)
82     include_directories(${SMACK_INCLUDE_DIRS})
83 endif()
85 if(WITH_LEVELDB)
86     # Find LevelDB
87     find_package(LevelDB REQUIRED)
88     include_directories(${LEVELDB_INCLUDE_DIRS})
89 endif()
91 # GoLD does no overlinking
92 find_package(Boost REQUIRED COMPONENTS thread system)
93 message(STATUS "Boost information:")
94 message(STATUS "  Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
95 message(STATUS "  Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
96 message(STATUS "  Boost_LIBRARIES: ${Boost_LIBRARIES}")
97 include_directories(${Boost_INCLUDE_DIRS})
98 link_directories(${Boost_LIBRARY_DIRS})
100 # Collect all libraries together
101 set(ELLIPTICS_LIBRARIES
102     ${SENDFILE_LIBRARIES}
103     ${Boost_LIBRARIES}
104     ${EBLOB_LIBRARIES}
105     ${ZMQ_LIBRARIES}
106     ${COCAINE_LIBRARIES}
107     ${CMAKE_THREAD_LIBS_INIT}
108     )
110 # Build parts
111 add_subdirectory(srw)
112 add_subdirectory(cache)
113 add_subdirectory(library)
114 add_subdirectory(bindings)
115 if(WITH_EXAMPLES)
116     add_subdirectory(example)
117 endif()
119 install(FILES
120         include/elliptics/core.h
121         include/elliptics/cppdef.h
122         include/elliptics/interface.h
123         include/elliptics/packet.h
124         include/elliptics/srw.h
125         ${CMAKE_BINARY_DIR}/include/elliptics/typedefs.h
126         DESTINATION include/elliptics/
127         )