2022-09-04 11:15:31 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2022-09-04 10:14:42 +00:00
|
|
|
|
2023-04-10 21:01:19 +00:00
|
|
|
project(LMDBAL
|
2024-02-04 19:10:43 +00:00
|
|
|
VERSION 0.5.4
|
2023-04-10 21:01:19 +00:00
|
|
|
DESCRIPTION "LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer"
|
|
|
|
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
|
|
|
|
2024-12-03 17:36:07 +00:00
|
|
|
set(LMDBAL_NAME ${PROJECT_NAME} CACHE STRING "Override for library name and install path")
|
|
|
|
|
2023-03-22 16:30:41 +00:00
|
|
|
option(BUILD_STATIC "Builds library as static library" OFF)
|
|
|
|
option(BUILD_TESTS "Builds tests" OFF)
|
2024-10-01 11:13:48 +00:00
|
|
|
option(BUILD_DOC_MAN "Builds man page documentation" OFF)
|
|
|
|
option(BUILD_DOC_HTML "Builds html documentation" OFF)
|
|
|
|
option(BUILD_DOC_XML "Builds xml documentation" OFF)
|
2023-04-09 17:19:23 +00:00
|
|
|
option(BUILD_DOXYGEN_AWESOME "Builds documentation alternative style" OFF)
|
2023-03-22 16:30:41 +00:00
|
|
|
|
2022-09-15 21:34:39 +00:00
|
|
|
include(GNUInstallDirs)
|
2023-03-22 16:30:41 +00:00
|
|
|
include(CMakePackageConfigHelpers)
|
2022-09-15 21:34:39 +00:00
|
|
|
|
2022-10-10 20:51:48 +00:00
|
|
|
set(CMAKE_AUTOMOC ON)
|
2022-09-04 11:15:31 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2024-01-31 13:13:27 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2022-09-04 11:15:31 +00:00
|
|
|
|
2024-12-03 17:36:07 +00:00
|
|
|
string(TOLOWER ${LMDBAL_NAME} LMDBAL_NAME_LOW)
|
|
|
|
|
2022-09-04 11:15:31 +00:00
|
|
|
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
|
|
|
if (BUILD_STATIC)
|
2024-12-03 17:36:07 +00:00
|
|
|
add_library(${LMDBAL_NAME} STATIC)
|
2022-09-15 21:34:39 +00:00
|
|
|
else ()
|
2024-12-03 17:36:07 +00:00
|
|
|
add_library(${LMDBAL_NAME} SHARED)
|
2022-09-15 21:34:39 +00:00
|
|
|
endif()
|
|
|
|
|
2023-04-02 13:00:21 +00:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
list(APPEND COMPILE_OPTIONS -O3)
|
|
|
|
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
list(APPEND COMPILE_OPTIONS -g)
|
|
|
|
list(APPEND COMPILE_OPTIONS -Wall)
|
|
|
|
list(APPEND COMPILE_OPTIONS -Wextra)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message("Compilation options: " ${COMPILE_OPTIONS})
|
2024-12-03 17:36:07 +00:00
|
|
|
target_compile_options(${LMDBAL_NAME} PRIVATE ${COMPILE_OPTIONS})
|
|
|
|
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY VERSION ${version})
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY SOVERSION 1)
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY EXPORT_NAME ${LMDBAL_NAME})
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY INTERFACE_${LMDBAL_NAME}_MAJOR_VERSION 1)
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} APPEND PROPERTY
|
|
|
|
COMPATIBLE_INTERFACE_STRING ${LMDBAL_NAME}_MAJOR_VERSION
|
2023-03-22 16:30:41 +00:00
|
|
|
)
|
|
|
|
|
2024-02-04 19:10:43 +00:00
|
|
|
if (UNIX)
|
2024-12-03 17:36:07 +00:00
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${LMDBAL_NAME_LOW}")
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY SKIP_BUILD_RPATH FALSE)
|
|
|
|
set_property(TARGET ${LMDBAL_NAME} PROPERTY BUILD_WITH_INSTALL_RPATH FALSE)
|
2024-02-04 19:10:43 +00:00
|
|
|
endif()
|
2024-02-01 16:05:49 +00:00
|
|
|
|
2023-03-21 11:05:54 +00:00
|
|
|
add_subdirectory(src)
|
2024-10-01 11:13:48 +00:00
|
|
|
if (BUILD_DOC_MAN OR BUILD_DOC_HTML OR BUILD_DOC_XML)
|
2023-03-23 17:27:46 +00:00
|
|
|
find_package(Doxygen)
|
|
|
|
if (DOXYGEN_FOUND)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
else()
|
|
|
|
message("Was trying to build documentation, but Doxygen was not found, skipping documentation")
|
|
|
|
endif()
|
|
|
|
endif()
|
2023-03-21 11:05:54 +00:00
|
|
|
|
2022-09-15 21:34:39 +00:00
|
|
|
if (BUILD_TESTS)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif ()
|
|
|
|
|
2024-02-01 16:05:49 +00:00
|
|
|
target_include_directories(
|
2024-12-03 17:36:07 +00:00
|
|
|
${LMDBAL_NAME}
|
2024-02-01 16:05:49 +00:00
|
|
|
PUBLIC
|
2024-12-03 17:36:07 +00:00
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LMDBAL_NAME_LOW}>
|
2024-02-01 16:05:49 +00:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
2024-02-04 22:49:06 +00:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serializer>
|
2024-02-01 16:05:49 +00:00
|
|
|
)
|
2024-12-03 17:36:07 +00:00
|
|
|
target_include_directories(${LMDBAL_NAME} PRIVATE ${Qt${QT_VERSION_MAJOR}_INCLUDE_DIRS})
|
|
|
|
target_include_directories(${LMDBAL_NAME} PRIVATE ${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS})
|
2023-03-22 16:30:41 +00:00
|
|
|
|
2024-02-01 16:05:49 +00:00
|
|
|
target_link_libraries(
|
2024-12-03 17:36:07 +00:00
|
|
|
${LMDBAL_NAME}
|
2024-02-01 16:05:49 +00:00
|
|
|
Qt${QT_VERSION_MAJOR}::Core
|
|
|
|
lmdb
|
2023-03-22 16:30:41 +00:00
|
|
|
)
|
2022-09-04 11:15:31 +00:00
|
|
|
|
2023-03-22 16:30:41 +00:00
|
|
|
configure_package_config_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
|
2024-12-03 17:36:07 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${LMDBAL_NAME_LOW}Config.cmake"
|
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LMDBAL_NAME_LOW}
|
2022-09-04 11:15:31 +00:00
|
|
|
)
|
2022-09-04 10:14:42 +00:00
|
|
|
|
2023-03-22 16:30:41 +00:00
|
|
|
write_basic_package_version_file(
|
2024-12-03 17:36:07 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${LMDBAL_NAME_LOW}ConfigVersion.cmake"
|
2023-03-22 16:30:41 +00:00
|
|
|
VERSION "${version}"
|
|
|
|
COMPATIBILITY AnyNewerVersion
|
|
|
|
)
|
|
|
|
|
2024-12-03 17:36:07 +00:00
|
|
|
install(TARGETS ${LMDBAL_NAME}
|
|
|
|
EXPORT ${LMDBAL_NAME_LOW}Targets
|
2024-02-04 22:49:06 +00:00
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2024-12-03 17:36:07 +00:00
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${LMDBAL_NAME_LOW}
|
2022-09-15 21:34:39 +00:00
|
|
|
)
|
|
|
|
|
2024-12-03 17:36:07 +00:00
|
|
|
install(EXPORT ${LMDBAL_NAME_LOW}Targets
|
|
|
|
FILE ${LMDBAL_NAME_LOW}Targets.cmake
|
|
|
|
NAMESPACE ${LMDBAL_NAME}::
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LMDBAL_NAME_LOW}
|
2023-03-22 16:30:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES
|
2024-12-03 17:36:07 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${LMDBAL_NAME_LOW}Config.cmake"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${LMDBAL_NAME_LOW}ConfigVersion.cmake"
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LMDBAL_NAME_LOW}
|
2023-03-22 16:30:41 +00:00
|
|
|
)
|