Fix typos, fix some warnings, added more compile options, moved to forgejo CI
This commit is contained in:
parent
3ae1fd15c0
commit
1585b8e4f5
15 changed files with 204 additions and 120 deletions
132
CMakeLists.txt
132
CMakeLists.txt
|
@ -1,9 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(LMDBAL
|
||||
VERSION 0.6.0
|
||||
DESCRIPTION "LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer"
|
||||
LANGUAGES CXX
|
||||
VERSION 0.6.0
|
||||
DESCRIPTION "LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
cmake_policy(SET CMP0076 NEW)
|
||||
|
@ -11,12 +11,16 @@ cmake_policy(SET CMP0079 NEW)
|
|||
|
||||
set(LMDBAL_NAME ${PROJECT_NAME} CACHE STRING "Override for library name and install path")
|
||||
|
||||
option(BUILD_STATIC "Builds library as static library" OFF)
|
||||
option(BUILD_TESTS "Builds tests" OFF)
|
||||
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)
|
||||
option(BUILD_DOXYGEN_AWESOME "Builds documentation alternative style" OFF)
|
||||
option(LMDBAL_BUILD_STATIC "Builds library as static library" OFF)
|
||||
option(LMDBAL_BUILD_TESTS "Builds tests" OFF)
|
||||
option(LMDBAL_BUILD_DOC_MAN "Builds man page documentation" OFF)
|
||||
option(LMDBAL_BUILD_DOC_HTML "Builds html documentation" OFF)
|
||||
option(LMDBAL_BUILD_DOC_XML "Builds xml documentation" OFF)
|
||||
option(LMDBAL_BUILD_DOXYGEN_AWESOME "Builds documentation alternative style" OFF)
|
||||
option(LMDBAL_STRICT "Builds with extra compiler warnings" OFF)
|
||||
option(LMDBAL_ASAN "Enables Address Sanitizer" OFF)
|
||||
option(LMDBAL_UBSAN "Enables Undefined Behavior Sanitizer" OFF)
|
||||
option(LMDBAL_TSAN "Enables Thread Sanitizer" OFF)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
@ -29,40 +33,80 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|||
string(TOLOWER ${LMDBAL_NAME} LMDBAL_NAME_LOW)
|
||||
|
||||
if (NOT DEFINED QT_VERSION_MAJOR)
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
|
||||
endif()
|
||||
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)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif ()
|
||||
|
||||
if (BUILD_STATIC)
|
||||
add_library(${LMDBAL_NAME} STATIC)
|
||||
if (LMDBAL_BUILD_STATIC)
|
||||
add_library(${LMDBAL_NAME} STATIC)
|
||||
else ()
|
||||
add_library(${LMDBAL_NAME} SHARED)
|
||||
add_library(${LMDBAL_NAME} SHARED)
|
||||
endif()
|
||||
|
||||
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()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
list(APPEND COMPILE_OPTIONS -Wall)
|
||||
list(APPEND COMPILE_OPTIONS -Wextra)
|
||||
list(APPEND COMPILE_OPTIONS -Wpedantic)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
list(APPEND COMPILE_OPTIONS -O3)
|
||||
list(APPEND COMPILE_OPTIONS -DNDEBUG)
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
list(APPEND COMPILE_OPTIONS -O0)
|
||||
list(APPEND COMPILE_OPTIONS -g3)
|
||||
list(APPEND COMPILE_OPTIONS -ggdb)
|
||||
endif ()
|
||||
|
||||
if (LMDBAL_STRICT)
|
||||
list(APPEND COMPILE_OPTIONS -Wall)
|
||||
list(APPEND COMPILE_OPTIONS -Werror)
|
||||
list(APPEND COMPILE_OPTIONS -Wconversion)
|
||||
list(APPEND COMPILE_OPTIONS -Wnon-virtual-dtor)
|
||||
list(APPEND COMPILE_OPTIONS -Wold-style-cast)
|
||||
list(APPEND COMPILE_OPTIONS -Wcast-align)
|
||||
list(APPEND COMPILE_OPTIONS -Wunused)
|
||||
list(APPEND COMPILE_OPTIONS -Woverloaded-virtual)
|
||||
list(APPEND COMPILE_OPTIONS -Wsign-conversion)
|
||||
list(APPEND COMPILE_OPTIONS -Wnull-dereference)
|
||||
endif ()
|
||||
|
||||
if(JAY_ENABLE_ASAN)
|
||||
list(APPEND COMPILE_OPTIONS -fsanitize=address)
|
||||
list(APPEND COMPILE_OPTIONS -fno-omit-frame-pointer)
|
||||
list(APPEND LINK_OPTIONS -fsanitize=address)
|
||||
add_link_options()
|
||||
endif()
|
||||
|
||||
if(JAY_ENABLE_UBSAN)
|
||||
list(APPEND COMPILE_OPTIONS -fsanitize=undefined)
|
||||
list(APPEND LINK_OPTIONS -fsanitize=undefined)
|
||||
endif()
|
||||
|
||||
if(JAY_ENABLE_TSAN)
|
||||
list(APPEND COMPILE_OPTIONS -fsanitize=thread)
|
||||
list(APPEND LINK_OPTIONS -fsanitize=thread)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
message("Compilation options: " ${COMPILE_OPTIONS})
|
||||
message("Linking options: " ${LINK_OPTIONS})
|
||||
target_compile_options(${LMDBAL_NAME} PRIVATE ${COMPILE_OPTIONS})
|
||||
target_link_options(${LMDBAL_NAME} PRIVATE ${LINK_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
|
||||
COMPATIBLE_INTERFACE_STRING ${LMDBAL_NAME}_MAJOR_VERSION
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
@ -70,36 +114,36 @@ if (UNIX)
|
|||
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)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
add_subdirectory(src)
|
||||
if (BUILD_DOC_MAN OR BUILD_DOC_HTML OR BUILD_DOC_XML)
|
||||
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()
|
||||
if (LMDBAL_BUILD_DOC_MAN OR LMDBAL_BUILD_DOC_HTML OR LMDBAL_BUILD_DOC_XML)
|
||||
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 ()
|
||||
|
||||
if (BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
if (LMDBAL_BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif ()
|
||||
|
||||
target_include_directories(
|
||||
${LMDBAL_NAME}
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LMDBAL_NAME_LOW}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serializer>
|
||||
${LMDBAL_NAME}
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LMDBAL_NAME_LOW}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/serializer>
|
||||
)
|
||||
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})
|
||||
|
||||
target_link_libraries(
|
||||
${LMDBAL_NAME}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
lmdb
|
||||
${LMDBAL_NAME}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
lmdb
|
||||
)
|
||||
|
||||
configure_package_config_file(
|
||||
|
@ -127,7 +171,7 @@ install(EXPORT ${LMDBAL_NAME_LOW}Targets
|
|||
)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${LMDBAL_NAME_LOW}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${LMDBAL_NAME_LOW}ConfigVersion.cmake"
|
||||
"${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}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue