Skip to content

Commit

Permalink
ejdb2 initial project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
adamansky committed May 7, 2018
1 parent 65a64c7 commit e1f9cea
Show file tree
Hide file tree
Showing 22 changed files with 1,225 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .astylerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--style=java
--pad-header
--pad-oper
--unpad-paren
--indent=spaces=2
--indent-classes
--indent-modifiers
--indent-preproc-define
--indent-col1-comments
--min-conditional-indent=0
--max-instatement-indent=120
--fill-empty-lines
--align-pointer=name
--align-reference=name
--convert-tabs
--close-templates
--max-code-length=120
--mode=c
--lineend=linux
--indent-switches
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=2

[Makefile]
indent_style = tab
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.codelite/
.cmaketools.json
*.tags
*.dll
build/
cmake-build*
.cmake_dirty
Makefile
Testing/
compile_commands.json
.idea/
*.iml
*.dat
*.db
148 changes: 148 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
include(CMakeToolsHelpers OPTIONAL)
set(DEB_CHANGELOG_REQUIRED ON)
set(DEB_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/Changelog")
unset(CHANGELOG_LAST_VERSION)
unset(CHANGELOG_LAST_MESSAGE)
include(DebChangelog)

set(PROJECT_NAME "ejdb2")
set(PROJECT_VENDOR "Softmotions (https://softmotions.com)")
set(PROJECT_WEBSITE "https://github.com/Softmotions/ejdb")
set(PROJECT_MAINTAINER "Anton Adamansky <adamansky@gmail.com>")
set(PROJECT_DESCRIPTION_SUMMARY "Embedded JSON database library (EJDB)")
set(PROJECT_DESCRIPTION "EJDB aims to be a fast MongoDB-like library which can be embedded into C/C++ applications.")
set(CHANGELOG_MESSAGE ${CHANGELOG_LAST_MESSAGE})
set(PROJECT_PPA "ppa:adamansky/ejdb2")
set(PROJECT_PPA_USER "adamansky")
set(PROJECT_PPA_DISTRIB_TARGET xenial artful)

project(${PROJECT_NAME} C)

set(PROJECT_VERSION_MAJOR ${CHANGELOG_LAST_VERSION_MAJOR})
set(PROJECT_VERSION_MINOR ${CHANGELOG_LAST_VERSION_MINOR})
set(PROJECT_VERSION_PATCH ${CHANGELOG_LAST_VERSION_PATCH})
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION})
set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(${PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(${PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH})

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_TESTS "Build test cases" OFF)
option(ASAN "Turn on address sanitizer" OFF)
option(BUILD_EXAMPLES "Build example projects" ON)
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
option(PACKAGE_DEB "Build .deb instalation packages" OFF)
option(PACKAGE_RPM "Build .rpm instalation packages" OFF)
option(PACKAGE_TGZ "Build .tgz package archive" ON)
option(PACKAGE_ZIP "Build .zip package archive" ON)
option(ENABLE_PPA "Enable PPA package build" OFF)
option(UPLOAD_PPA "Upload debian packages to the launchpad ppa repository" OFF)
option(PPA_DEBIAN_VERSION "PPA version suffix for debian packages" "ppa1")
option("PROJECT_PPA_DISTRIB_TARGET" "Ubuntu PPA distrubutive names" "xenial;artful")

if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)

include(GNUInstallDirs)
include(ProjectUtils)

macro_ensure_out_of_source_build(
"${CMAKE_PROJECT_NAME} requires an out of source build."
)

if(BUILD_TESTS)
include(CTest)
find_package(CUnit REQUIRED)
endif(BUILD_TESTS)

if(UPLOAD_PPA)
set(ENABLE_PPA ON)
endif(UPLOAD_PPA)

# add a target to generate API documentation with Doxygen
find_package(Doxygen)
option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" OFF)

if(BUILD_DOCUMENTATION)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif()
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} docs)")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
endif()

add_subdirectory(man)

if(NOT ENABLE_PPA)
add_subdirectory(src)
else()
set(PACKAGE_DEB ON)
endif()

set(CPACK_GENERATORS)
if(PACKAGE_TGZ)
list(APPEND CPACK_GENERATORS "TGZ")
endif()
if(PACKAGE_ZIP)
list(APPEND CPACK_GENERATORS "ZIP")
endif()
if(PACKAGE_DEB)
list(APPEND CPACK_GENERATORS "DEB")
endif()
if(PACKAGE_RPM)
list(APPEND CPACK_GENERATORS "RPM")
endif()

if(CPACK_GENERATORS)
set(CPACK_GENERATOR "${CPACK_GENERATORS}")
set(CPACK_SOURCE_IGNORE_FILES
"/mxe/"
"/\\\\.vscode/"
"/\\\\.codelite/"
"/\\\\.idea/"
"/cmake-.*/"
"\\\\.sh$"
"\\\\.project$"
"\\\\.workspace$"
"\\\\.iml$"
"\\\\.mk$"
"\\\\.astylerc$"
"\\\\.editorconfig$"
"/Makefile$"
)
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(PROJECT_ARCH "x86_64")
else()
set(PROJECT_ARCH "x86")
endif()
add_subdirectory(installer)
endif(CPACK_GENERATORS)

message("${PROJECT_NAME} CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message("${PROJECT_NAME} CPACK_GENERATORS: ${CPACK_GENERATORS}")
if (MXE_HOME)
message("${PROJECT_NAME} MXE_HOME: ${MXE_HOME}")
endif()
if(CMAKE_SYSTEM_NAME)
message("${PROJECT_NAME} CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
endif()
if(CMAKE_SIZEOF_VOID_P)
message("${PROJECT_NAME} SIZEOF *VOID: ${CMAKE_SIZEOF_VOID_P}")
endif()
message("${PROJECT_NAME} PROJECT: ${CHANGELOG_LAST_LINE}")
if(CHANGELOG_MESSAGE)
message("${PROJECT_NAME} CHANGELOG_MESSAGE:\n ${CHANGELOG_MESSAGE}")
endif()
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ejdb2 (1.0.0) UNRELEASED; urgency=medium

* Initial release

-- Anton Adamansky <adamansky@gmail.com> Mon, 07 May 2018 22:46:16 +0700
54 changes: 54 additions & 0 deletions cmake/Modules/DebChangelog.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## -*- mode:cmake; coding:utf-8; -*-
# Set output:
# CHANGELOG_LAST_LINE
# CHANGELOG_LAST_VERSION - Last changelog version
# CHANGELOG_LAST_VERSION_MAJOR - Last changelog major version
# CHANGELOG_LAST_VERSION_MINOR - Last changelog minor version
# CHANGELOG_LAST_VERSION_PATCH - Last changelog patch version
# CHANGELOG_LAST_MESSAGE - Last changelog description

if (NOT DEB_CHANGELOG)
set(DEB_CHANGELOG "${CMAKE_SOURCE_DIR}/Changelog")
endif()

if (NOT EXISTS ${DEB_CHANGELOG})
if (DEB_CHANGELOG_REQUIRED)
message(FATAL_ERROR "Missing required project changelog file: ${DEB_CHANGELOG}")
else()
message("Missing project changelog file: ${DEB_CHANGELOG}")
return()
endif()
endif()
message(STATUS "Using project changelog file: ${DEB_CHANGELOG}")

file(STRINGS "${DEB_CHANGELOG}" _DEBCHANGELOGN)

foreach(CLINE IN LISTS _DEBCHANGELOGN)
if (NOT CHANGELOG_LAST_VERSION)
#ejdb (1.2.6) testing; urgency=low
string(REGEX MATCH "^[A-Za-z0-9_].*[ \t]+\\((([0-9]+)\\.([0-9]+)\\.([0-9]+))\\)[ \t]+[A-Za-z]+;[ \t].*" _MATCHED "${CLINE}")
if (_MATCHED)
set(CHANGELOG_LAST_LINE "${_MATCHED}")
set(CHANGELOG_LAST_VERSION "${CMAKE_MATCH_1}")
set(CHANGELOG_LAST_VERSION_MAJOR "${CMAKE_MATCH_2}")
set(CHANGELOG_LAST_VERSION_MINOR "${CMAKE_MATCH_3}")
set(CHANGELOG_LAST_VERSION_PATCH "${CMAKE_MATCH_4}")
endif()
elseif(NOT CHANGELOG_LAST_MESSAGE)
string(REGEX MATCH "^[A-Za-z0-9_].*[ \t]+\\((([0-9]+)\\.([0-9]+)\\.([0-9]+))\\)[ \t]+[A-Za-z]+;[ \t].*" _MATCHED "${CLINE}")
if (_MATCHED)
string(STRIP "${_CDESC}" CHANGELOG_LAST_MESSAGE)
return()
endif()
if (CLINE)
string(REGEX MATCH "^[ \t]*\\-\\-[ \t]+" _MATCHED "${CLINE}")
if (_MATCHED)
string(STRIP "${_CDESC}" CHANGELOG_LAST_MESSAGE)
return()
endif()
set(_CDESC "${_CDESC}\n${CLINE}")
endif()
endif()
endforeach(CLINE)

message(FATAL_ERROR "Invalid changelog file: ${DEB_CHANGELOG}")
24 changes: 24 additions & 0 deletions cmake/Modules/FindCUnit.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Find the CUnit headers and libraries
#
# CUNIT_INCLUDE_DIRS - The CUnit include directory (directory where CUnit/CUnit.h was found)
# CUNIT_LIBRARIES - The libraries needed to use CUnit
# CUNIT_FOUND - True if CUnit found in system


FIND_PATH(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h)
MARK_AS_ADVANCED(CUNIT_INCLUDE_DIR)

FIND_LIBRARY(CUNIT_LIBRARY NAMES
cunit
libcunit
cunitlib
)
MARK_AS_ADVANCED(CUNIT_LIBRARY)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR)

IF(CUNIT_FOUND)
SET(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
SET(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
ENDIF(CUNIT_FOUND)
40 changes: 40 additions & 0 deletions cmake/Modules/FindLibIberty.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# - Find Iberty
# This module finds libiberty.
#
# It sets the following variables:
# IBERTY_LIBRARIES - The libiberty library to link against.

# For Debian <= wheezy, use libiberty_pic.a from binutils-dev
# For Debian >= jessie, use libiberty.a from libiberty-dev
# For all RHEL/Fedora, use libiberty.a from binutils-devel
FIND_LIBRARY( IBERTY_LIBRARIES
NAMES iberty_pic iberty
HINTS ${IBERTY_LIBRARIES}
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/opt/local/lib64
/sw/lib
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH
)

IF (IBERTY_LIBRARIES)

# show which libiberty was found only if not quiet
MESSAGE( STATUS "Found libiberty: ${IBERTY_LIBRARIES}")

SET(IBERTY_FOUND TRUE)

ELSE (IBERTY_LIBRARIES)

IF (IBERTY_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libiberty. Try to install binutil-devel?")
ELSE()
MESSAGE(STATUS "Could not find libiberty; downloading binutils and building PIC libiberty.")
ENDIF (IBERTY_FIND_REQUIRED)

ENDIF (IBERTY_LIBRARIES)
10 changes: 10 additions & 0 deletions cmake/Modules/ProjectUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


macro(MACRO_ENSURE_OUT_OF_SOURCE_BUILD MSG)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
get_filename_component(PARENTDIR ${CMAKE_SOURCE_DIR} PATH)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir)
if(insource OR insourcesubdir)
message(FATAL_ERROR "${MSG}")
endif(insource OR insourcesubdir)
endmacro(MACRO_ENSURE_OUT_OF_SOURCE_BUILD)
Loading

0 comments on commit e1f9cea

Please sign in to comment.