2022-09-04 11:15:31 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2022-09-04 10:14:42 +00:00
|
|
|
|
2022-09-04 11:15:31 +00:00
|
|
|
project(storage VERSION 0.0.1 LANGUAGES CXX)
|
2022-09-04 10:14:42 +00:00
|
|
|
|
2022-09-04 11:15:31 +00:00
|
|
|
cmake_policy(SET CMP0076 NEW)
|
|
|
|
cmake_policy(SET CMP0079 NEW)
|
2022-09-15 21:34:39 +00:00
|
|
|
|
|
|
|
option(BUILD_STATIC "Builds library as static library" ON)
|
|
|
|
option(BUILD_TESTS "Builds tests" ON)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2022-10-10 20:51:48 +00:00
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
2022-09-04 11:15:31 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
|
|
|
|
if (NOT DEFINED QT_VERSION_MAJOR)
|
|
|
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
|
|
|
|
endif()
|
|
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
|
|
|
|
|
|
|
find_package(LMDB REQUIRED)
|
|
|
|
|
|
|
|
# Build type
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
|
|
endif ()
|
|
|
|
|
2022-09-15 21:34:39 +00:00
|
|
|
set(SOURCES
|
2022-09-09 17:15:40 +00:00
|
|
|
exceptions.cpp
|
2022-09-05 20:25:39 +00:00
|
|
|
table.cpp
|
|
|
|
database.cpp
|
2022-09-04 11:15:31 +00:00
|
|
|
)
|
|
|
|
|
2022-09-15 21:34:39 +00:00
|
|
|
set(HEADERS
|
|
|
|
database.h
|
|
|
|
exceptions.h
|
|
|
|
table.h
|
|
|
|
table.hpp
|
2022-09-20 17:16:48 +00:00
|
|
|
cache.h
|
|
|
|
cache.hpp
|
2022-09-15 21:34:39 +00:00
|
|
|
serializer.h
|
|
|
|
serializer.hpp
|
|
|
|
serializer_uint8.hpp
|
|
|
|
serializer_uint16.hpp
|
|
|
|
serializer_uint32.hpp
|
|
|
|
serializer_uint64.hpp
|
2022-09-17 12:31:58 +00:00
|
|
|
serializer_int8.hpp
|
|
|
|
serializer_int16.hpp
|
|
|
|
serializer_int32.hpp
|
|
|
|
serializer_int64.hpp
|
|
|
|
serializer_float.hpp
|
|
|
|
serializer_double.hpp
|
|
|
|
serializer_stdstring.hpp
|
|
|
|
serializer_qstring.hpp
|
2022-10-15 10:54:34 +00:00
|
|
|
serializer_qbytearray.hpp
|
2022-09-15 21:34:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if (BUILD_STATIC)
|
|
|
|
add_library(storage STATIC ${SOURCES})
|
|
|
|
else ()
|
|
|
|
add_library(storage SHARED ${SOURCES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (BUILD_TESTS)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set_target_properties(storage PROPERTIES PUBLIC_HEADER "${HEADERS}")
|
2022-09-04 11:15:31 +00:00
|
|
|
|
2022-10-10 20:51:48 +00:00
|
|
|
target_include_directories(storage PUBLIC ${CMAKE_SOURCE_DIR})
|
|
|
|
target_include_directories(storage PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
2022-09-04 11:15:31 +00:00
|
|
|
target_include_directories(storage PRIVATE ${Qt${QT_VERSION_MAJOR}_INCLUDE_DIRS})
|
|
|
|
target_include_directories(storage PRIVATE ${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
target_link_libraries(storage
|
|
|
|
PRIVATE
|
|
|
|
Qt${QT_VERSION_MAJOR}::Core
|
|
|
|
)
|
|
|
|
target_link_libraries(storage PRIVATE lmdb)
|
2022-09-04 10:14:42 +00:00
|
|
|
|
2022-09-15 21:34:39 +00:00
|
|
|
install(TARGETS storage
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/storage
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/storage
|
|
|
|
)
|
|
|
|
|