summaryrefslogtreecommitdiffstats
path: root/src/rgw/driver/dbstore/CMakeLists.txt
blob: a3aca7a64e4cc1e97424dbb5b29574f4d1658219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#need to update cmake version here
cmake_minimum_required(VERSION 3.14.0)
project(dbstore)

option(USE_SQLITE "Enable SQLITE DB" ON)

set (CMAKE_INCLUDE_DIR ${CMAKE_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/common")

set(dbstore_srcs
    common/dbstore_log.h
    common/dbstore.h
    common/dbstore.cc
    config/store.cc)
IF(USE_SQLITE)
  list(APPEND dbstore_srcs
      config/sqlite.cc
      sqlite/connection.cc
      sqlite/error.cc
      sqlite/statement.cc)
endif()

set(dbstore_mgr_srcs
    dbstore_mgr.h
    dbstore_mgr.cc
    )

add_library(dbstore_lib ${dbstore_srcs})
target_include_directories(dbstore_lib
    PUBLIC "${CMAKE_SOURCE_DIR}/src/rgw"
    PUBLIC "${CMAKE_SOURCE_DIR}/src/rgw/store/rados"
    PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
set(link_targets spawn)
if(WITH_JAEGER)
  list(APPEND link_targets jaeger_base)
endif()
list(APPEND link_targets rgw_common)
target_link_libraries(dbstore_lib PUBLIC ${link_targets})

set (CMAKE_LINK_LIBRARIES ${CMAKE_LINK_LIBRARIES} dbstore_lib)

IF(USE_SQLITE)
  add_subdirectory(sqlite)
  set(CMAKE_INCLUDE_DIR ${CMAKE_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/sqlite")
  add_compile_definitions(SQLITE_ENABLED=1)
  set (CMAKE_LINK_LIBRARIES ${CMAKE_LINK_LIBRARIES} rgw_common)
  set (CMAKE_LINK_LIBRARIES ${CMAKE_LINK_LIBRARIES} sqlite_db)
  add_dependencies(sqlite_db dbstore_lib)
ENDIF()

# add pthread library
set (CMAKE_LINK_LIBRARIES ${CMAKE_LINK_LIBRARIES} pthread)

find_package(gtest QUIET)
if(WITH_TESTS)
    add_subdirectory(tests)
else()
	message(WARNING "Gtest not enabled")
endif()

include_directories(${CMAKE_INCLUDE_DIR})
add_library(dbstore STATIC ${dbstore_mgr_srcs})
target_link_libraries(dbstore ${CMAKE_LINK_LIBRARIES})

# testing purpose
set(dbstore_main_srcs
    dbstore_main.cc)

set (CMAKE_LINK_LIBRARIES ${CMAKE_LINK_LIBRARIES} dbstore)
add_executable(dbstore-bin ${dbstore_main_srcs})
add_dependencies(dbstore-bin dbstore)
target_link_libraries(dbstore-bin ${CMAKE_LINK_LIBRARIES})