Commit cc55f809 authored by Martin Hoeher's avatar Martin Hoeher

Add CMake Build Files

Added CMake files to allow building the project using this build system.
parent 0a77e8fc
Pipeline #26201269 passed with stages
in 2 minutes and 43 seconds
......@@ -19,6 +19,27 @@ fedora-buitlin-lmdb:
- ./bin/ci/build-and-test-builtin-lmdb.sh
fedora-cmake:
stage: build
image: fedora
script:
- ./bin/ci/build-and-test-cmake.sh
fedora-cmake-static:
stage: build
image: fedora
script:
- ./bin/ci/build-and-test-cmake-static.sh
fedora-cmake-static:
stage: build
image: fedora
script:
- ./bin/ci/build-and-test-cmake-builtin-lmdb.sh
pages:
stage: build
image: fedora
......
cmake_minimum_required(VERSION 3.1.0)
project(qlmdb)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Define options users can set to change details of the build:
option(QLMDB_WITH_STATIC_LIBS "Build QLMDB as static library." OFF)
option(QLMDB_WITH_BUILTIN_LMDB "Build QLMDB with a built-in version of LMDB." OFF)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# Find the QtCore library
find_package(Qt5Core CONFIG REQUIRED)
find_package(Qt5Test CONFIG REQUIRED)
# Enable testing
enable_testing()
add_subdirectory(qlmdb)
add_subdirectory(tests)
......@@ -16,3 +16,6 @@ cd build/fedora-builtin-lmdb
qmake-qt5 CONFIG+=qlmdb_with_builtin_lmdb ../..
make -j4
make check
ls qlmdb | grep libqlmdb.so
! (ldd qlmdb/libqlmdb.so | grep liblmdb.so)
#!/bin/bash
set -e
SCRIPT_DIR="$(cd $(dirname "$0") && pwd)"
cd "$SCRIPT_DIR"
cd ..
cd ..
if [ -n "$CI" ]; then
dnf install -y gcc gcc-c++ make qt5-qtbase-devel cmake
fi
mkdir -p build/fedora-cmake-builtin-lmdb
cd build/fedora-cmake-builtin-lmdb
cmake -DQLMDB_WITH_BUILTIN_LMDB=ON ../..
make -j4
make test
ls qlmdb | grep libqlmdb.so
! (ldd qlmdb/libqlmdb.so | grep liblmdb.so)
#!/bin/bash
set -e
SCRIPT_DIR="$(cd $(dirname "$0") && pwd)"
cd "$SCRIPT_DIR"
cd ..
cd ..
if [ -n "$CI" ]; then
dnf install -y gcc gcc-c++ make qt5-qtbase-devel lmdb-devel cmake
fi
mkdir -p build/fedora-cmake-static
cd build/fedora-cmake-static
cmake -DQLMDB_WITH_STATIC_LIBS=ON ../..
make -j4
make test
ls qlmdb | grep libqlmdb.a
#!/bin/bash
set -e
SCRIPT_DIR="$(cd $(dirname "$0") && pwd)"
cd "$SCRIPT_DIR"
cd ..
cd ..
if [ -n "$CI" ]; then
dnf install -y gcc gcc-c++ make qt5-qtbase-devel lmdb-devel cmake
fi
mkdir -p build/fedora-cmake
cd build/fedora-cmake
cmake ../..
make -j4
make test
ls qlmdb | grep libqlmdb.so
ldd qlmdb/libqlmdb.so | grep liblmdb.so
......@@ -16,3 +16,5 @@ cd build/fedora-static
qmake-qt5 CONFIG+=qlmdb_with_static_libs ../..
make -j4
make check
ls qlmdb | grep libqlmdb.a
......@@ -16,3 +16,6 @@ cd build/fedora
qmake-qt5 ../..
make -j4
make check
ls qlmdb | grep libqlmdb.so
ldd qlmdb/libqlmdb.so | grep liblmdb.so
......@@ -11,4 +11,5 @@ OTHER_FILES += \
Doxyfile \
README.md \
$$files(bin/ci/*.sh) \
$$files(bin/*)
$$files(bin/*) \
$$files(CMakeLists.txt,true)
set(
QLMDB_HEADERS
qlmdb_global.h
errors.h
contextprivate.h
databaseprivate.h
cursorprivate.h
context.h
cursor.h
database.h
transactionprivate.h
transaction.h
)
set(
QLMDB_SOURCES
cursorprivate.cpp
context.cpp
contextprivate.cpp
errors.cpp
transactionprivate.cpp
databaseprivate.cpp
cursor.cpp
database.cpp
transaction.cpp
)
if(QLMDB_WITH_STATIC_LIBS)
set(QLMDB_LIB_MODE STATIC)
else()
set(QLMDB_LIB_MODE SHARED)
endif()
if(QLMDB_WITH_BUILTIN_LMDB)
set(
LMDB_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/liblmdb/mdb.c
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/liblmdb/midl.c
)
set(
LMDB_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/liblmdb/lmdb.h
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/liblmdb/midl.h
)
set(
LMDB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/liblmdb
)
else()
set(
LMDB_LIBS
lmdb
)
endif()
add_library(
qlmdb
${QLMDB_LIB_MODE}
${QLMDB_HEADERS}
${QLMDB_SOURCES}
${LMDB_SOURCES}
${LMDB_HEADERS}
)
target_link_libraries(qlmdb PUBLIC Qt5::Core ${LMDB_LIBS})
target_include_directories(
qlmdb
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/../
)
target_include_directories(
qlmdb
PRIVATE
${LMDB_INCLUDE_DIRS}
)
add_subdirectory(context)
add_subdirectory(cursor)
add_subdirectory(database)
add_subdirectory(transaction)
add_executable(
tst_context
tst_context_test.cpp
)
target_link_libraries(
tst_context
Qt5::Core
Qt5::Test
qlmdb
)
add_test(NAME context COMMAND tst_context)
......@@ -18,8 +18,8 @@
#include <QTemporaryDir>
#include <QtTest>
#include "context.h"
#include "errors.h"
#include "qlmdb/context.h"
#include "qlmdb/errors.h"
using namespace QLMDB;
......
add_executable(
tst_cursor
tst_cursor_test.cpp
)
target_link_libraries(
tst_cursor
Qt5::Core
Qt5::Test
qlmdb
)
add_test(NAME cursor COMMAND tst_cursor)
......@@ -19,11 +19,11 @@
#include <QTemporaryFile>
#include <QtTest>
#include "context.h"
#include "cursor.h"
#include "database.h"
#include "errors.h"
#include "transaction.h"
#include "qlmdb/context.h"
#include "qlmdb/cursor.h"
#include "qlmdb/database.h"
#include "qlmdb/errors.h"
#include "qlmdb/transaction.h"
using namespace QLMDB;
......
add_executable(
tst_database
tst_database_test.cpp
)
target_link_libraries(
tst_database
Qt5::Core
Qt5::Test
qlmdb
)
add_test(NAME database COMMAND tst_database)
......@@ -19,10 +19,10 @@
#include <QTemporaryDir>
#include <QtTest>
#include "context.h"
#include "database.h"
#include "errors.h"
#include "transaction.h"
#include "qlmdb/context.h"
#include "qlmdb/database.h"
#include "qlmdb/errors.h"
#include "qlmdb/transaction.h"
using namespace QLMDB;
......
......@@ -24,5 +24,5 @@ LIBS += -lqlmdb
QMAKE_RPATHDIR = $$OUT_PWD/../../qlmdb
INCLUDEPATH += $$PWD/../qlmdb
INCLUDEPATH += $$PWD/../
DEPENDPATH += $$PWD/../qlmdb
add_executable(
tst_transaction
tst_transaction_test.cpp
)
target_link_libraries(
tst_transaction
Qt5::Core
Qt5::Test
qlmdb
)
add_test(NAME transaction COMMAND tst_transaction)
......@@ -18,9 +18,9 @@
#include <QTemporaryDir>
#include <QtTest>
#include "context.h"
#include "transaction.h"
#include "errors.h"
#include "qlmdb/context.h"
#include "qlmdb/transaction.h"
#include "qlmdb/errors.h"
using namespace QLMDB;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment