Skip to content

Commit

Permalink
Merge pull request #564 from fnc12/dev
Browse files Browse the repository at this point in the history
v1.6
  • Loading branch information
fnc12 authored Oct 8, 2020
2 parents f51a734 + 76f4d7c commit 4c6a46b
Show file tree
Hide file tree
Showing 142 changed files with 11,696 additions and 6,741 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/clang-format-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ jobs:
- uses: actions/checkout@v1
- name: clang-format lint
uses: DoozyX/[email protected]
with:
exclude: ./include
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ examples/simple_neural_network.cpp
cmake-build-debug/

.idea/

/compile
94 changes: 45 additions & 49 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Defaults
os: linux
dist: xenial
dist: bionic

matrix:
include:
Expand Down Expand Up @@ -38,18 +38,18 @@ matrix:
env:
- SQLITE_ORM_OMITS_CODECVT: ON

- name: "[C++14] AppleClang-10.0.1"
os: osx
osx_image: xcode10.2
language: cpp
env:
- SQLITE_ORM_OMITS_CODECVT: ON
addons:
homebrew:
packages:
- catch2
- ninja
update: true
# - name: "[C++14] AppleClang-10.0.1"
# os: osx
# osx_image: xcode10.2
# language: cpp
# env:
# - SQLITE_ORM_OMITS_CODECVT: ON
# addons:
# homebrew:
# packages:
# - catch2
# - ninja
# update: true

# - name: "[C++14] LLVM/Clang (latest)"
# os: osx
Expand All @@ -71,19 +71,19 @@ matrix:
# - CXX: /usr/local/opt/llvm/bin/clang++
# - SQLITE_ORM_OMITS_CODECVT: ON

- name: "[C++14] GCC-6"
os: osx
osx_image: xcode10.2
addons:
homebrew:
packages:
- gcc@6
- catch2
- ninja
update: true
env:
- CC: gcc-6
- CXX: g++-6
# - name: "[C++14] GCC-6"
# os: osx
# osx_image: xcode10.2
# addons:
# homebrew:
# packages:
# - gcc@6
# - catch2
# - ninja
# update: true
# env:
# - CC: gcc-6
# - CXX: g++-6

- name: "[C++17] GCC-9"
addons:
Expand Down Expand Up @@ -111,19 +111,19 @@ matrix:
- CXX: g++-7
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"

- name: "[C++17] AppleClang-10.0.1"
os: osx
osx_image: xcode10.2
language: cpp
env:
- SQLITE_ORM_OMITS_CODECVT: ON
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
addons:
homebrew:
packages:
- catch2
- ninja
update: true
# - name: "[C++17] AppleClang-10.0.1"
# os: osx
# osx_image: xcode10.2
# language: cpp
# env:
# - SQLITE_ORM_OMITS_CODECVT: ON
# - SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
# addons:
# homebrew:
# packages:
# - catch2
# - ninja
# update: true

# - name: "[C++17] LLVM/Clang (latest)"
# os: osx
Expand Down Expand Up @@ -151,16 +151,12 @@ before_install:
if [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" # Use coreutils from homebrew.
fi
install:
- |
# Catch2 test framework
if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
git clone --depth=1 --quiet https://github.com/catchorg/Catch2.git
cd Catch2
cmake -Bbuild -H. -DBUILD_TESTING=OFF
sudo env "PATH=$PATH" cmake --build ./build --target install
fi
# Add ppa repo for cmake and delete cmake 3.12.4 folder of travis
- wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
- sudo apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main'
- sudo apt-get update -qq -y
- sudo apt-get install -y cmake
- sudo rm -r /usr/local/cmake-3.12.4/

# scripts to run before build
before_script:
Expand Down
56 changes: 20 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required (VERSION 3.2)
cmake_policy(SET CMP0057 NEW)
cmake_minimum_required (VERSION 3.16.0)

# Handling C++ standard version to use
option(SQLITE_ORM_ENABLE_CXX_17 "Enable C++ 17" OFF)
Expand All @@ -23,32 +22,29 @@ set(PACKAGE_VERSION ${sqlite_orm_VERSION})

project("sqlite_orm" VERSION ${PACKAGE_VERSION})


set(CMAKE_VERBOSE_MAKEFILE ON)

message(STATUS "Configuring ${CMAKE_PROJECT_NAME} ${sqlite_orm_VERSION}")

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")

# Build time options are defined here
include(DefineInstallationPaths)

# Generate the SqliteOrmConfig.cmake module
include(GenerateConfigModule)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

set(ProjectName "SqliteOrm")
include(CTest)

option(SqliteOrm_BuildTests "Build sqlite_orm unit tests" ON)
### Dependencies
add_subdirectory(dependencies)

### Main Build Targets
set(SqliteOrm_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include")
add_library(sqlite_orm INTERFACE)
add_library(sqlite_orm::sqlite_orm ALIAS sqlite_orm)

find_package(SQLite3 REQUIRED)
target_link_libraries(sqlite_orm INTERFACE SQLite::SQLite3)

target_sources(sqlite_orm INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/sqlite_orm/sqlite_orm.h>
$<INSTALL_INTERFACE:include/sqlite_orm/sqlite_orm.h>)
target_sources(sqlite_orm INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/sqlite_orm/sqlite_orm.h>)

target_include_directories(sqlite_orm INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(sqlite_orm INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)

include(ucm)

Expand All @@ -69,26 +65,14 @@ ucm_print_flags()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

# Tests
include(CTest)
if(SqliteOrm_BuildTests AND BUILD_TESTING)
enable_testing()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(tests)
endif()

add_subdirectory(examples)

install(TARGETS sqlite_orm EXPORT "${ProjectName}Targets"
INCLUDES DESTINATION "${INCLUDE_INSTALL_DIR}" COMPONENT Development
PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}" COMPONENT Development)

install(FILES "include/sqlite_orm/sqlite_orm.h"
DESTINATION "${INCLUDE_INSTALL_DIR}" COMPONENT Development)

export(EXPORT "${ProjectName}Targets"
FILE "${CMAKE_CURRENT_BINARY_DIR}/${ProjectName}/${ProjectName}Targets.cmake"
NAMESPACE "sqlite_orm::")
option(BUILD_EXAMPLES ON)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

install(EXPORT "${ProjectName}Targets"
FILE "${ProjectName}Targets.cmake"
NAMESPACE "sqlite_orm::"
DESTINATION "${CMAKE_INSTALL_DIR}/sqlite_orm")
### Packaging
add_subdirectory(packaging)
50 changes: 37 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ SQLite ORM light header only library for modern C++
* **Easy integration** - single header only lib.
* **The only dependency** - libsqlite3
* **C++ standard code style**
* **No undefined behaviour** - if something goes wrong lib throws an exception
* **In memory database support** - provide `:memory:` or empty filename
* **COLLATE support**
* **Limits setting/getting support**
Expand Down Expand Up @@ -754,31 +753,56 @@ For more details please check the project [wiki](https://github.com/fnc12/sqlite

# Installation

Use popular package manager like [vcpkg](https://github.com/Microsoft/vcpkg) and just install it with `vcpkg install sqlite-orm` command.
**Note**: Installation is not necessary if you plan to use the fetchContent method, see below in Usage.

Or you can use below instructions
Use a popular package manager like [vcpkg](https://github.com/Microsoft/vcpkg) and just install it with the `vcpkg install sqlite-orm` command.

Or you build it from source:

```bash
git clone https://github.com/fnc12/sqlite_orm.git sqlite_orm
cd sqlite_orm
mkdir compile
cd compile
cmake ..
cmake --build .
sudo make install
cmake -B build
cmake --build build --target install
```
You might need admin rights for the last command.

# Usage

## CMake

If you use cmake, there are two supported ways how to use it with cmake (if another works as well or should be supported, open an issue).

then you can just include `sqlite_orm.h` that is installed in system-wide header files location or in case you use cmake build system you can just add below commands in CMakeLists.txt
Either way you choose, the include path as well as the dependency sqlite3 will be set automatically on your target. So usage is straight forward, but you need to have installed sqlite3 on your system (see Requirements below)

## Find Package

If you have installed the lib system wide and it's in your PATH, you can use find_package to include it in cmake. It will make a target `sqlite_orm::sqlite_orm` available which you can link against. Have a look at examples/find_package for a full example.

```cmake
find_package(sqlite_orm CONFIG REQUIRED)
find_package(SqliteOrm REQUIRED)
target_link_libraries(main PRIVATE sqlite_orm::sqlite_orm)
target_include_directories(main PRIVATE ${SQLITE_ORM_INCLUDE_DIR})
```

Or just put `include/sqlite_orm/sqlite_orm.h` into you folder with headers. Also it is recommended to keep project libraries' sources in separate folders cause there is no dominant normal dependency manager for C++ yet.
## Fetch Content (Recommended)

Alternatively, cmake can download the project directly from github during configure stage and therefore you don't need to install the lib before.
Againt a target `sqlite_orm::sqlite_orm` will be available which you can link against. Have a look at examples/fetch_content for a full example.

## No CMake

If you want to use the lib directly with Make or something else, just set the inlcude path correctly (should be correct on Linux already), so `sqlite_orm/sqlite_orm.h` is found. As this is a header only lib, there is nothing more you have to do.

# Requirements

* C++14 compatible compiler (not C++11 cause of templated lambdas in the lib).
* libsqlite3 linked to your binary
* Sqlite3 installed on your system and in the path, so cmake can find it (or linked to you project if you don't use cmake)

# Video from conference

[![Video from conference](https://img.youtube.com/vi/ngsilquWgpo/0.jpg)](https://www.youtube.com/watch?v=ngsilquWgpo)

# SqliteMan

In case you need a native SQLite client for macOS or Windows 10 you can use SqliteMan https://sqliteman.dev. It is not a commercial. It is a free native client being developed by the maintainer of this repo.
9 changes: 4 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

`sqlite_orm` is a wonderful library but there are still features that are not implemented. Here you can find a list of them:

* `FOREIGN KEY` - sync_schema fk comparison and ability of two tables to have fk to each other
* `FOREIGN KEY` - sync_schema fk comparison and ability of two tables to have fk to each other (`PRAGMA foreign_key_list(%table_name%);` may be useful)
* rest of core functions(https://sqlite.org/lang_corefunc.html)
* `ATTACH`
* blob incremental I/O https://sqlite.org/c3ref/blob_open.html
* reusing of prepared statements - useful for query optimisation
* explicit FROM for subqueries in FROM argument
* backup API https://www.sqlite.org/backup.html
* busy handler https://sqlite.org/c3ref/busy_handler.html
* CREATE VIEW and other view operations https://sqlite.org/lang_createview.html
* triggers
* query static check for correct order (e.g. `GROUP BY` after `WHERE`)
* `WINDOW`
* `UPSERT` https://www.sqlite.org/lang_UPSERT.html
* `CHECK` constraint
* `SAVEPOINT` https://www.sqlite.org/lang_savepoint.html
* add `static_assert` in crud `get*` functions in case user passes `where_t` instead of id to make compilation error more clear (example https://github.com/fnc12/sqlite_orm/issues/485)
* generated columns https://www.sqlite.org/gencol.html
* named constraints: constraint can have name `CREATE TABLE heroes(id INTEGER CONSTRAINT pk PRIMARY KEY)`

Please feel free to add any feature that isn't listed here and not implemented yet.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ init:

install:
- C:\Tools\vcpkg\vcpkg integrate install
- vcpkg install catch2:%PLATFORM%-windows
- vcpkg install sqlite3:%PLATFORM%-windows

# scripts to run before build
before_build:
Expand Down
12 changes: 0 additions & 12 deletions build/cmake/DefineInstallationPaths.cmake

This file was deleted.

24 changes: 0 additions & 24 deletions build/cmake/GenerateConfigModule.cmake

This file was deleted.

22 changes: 0 additions & 22 deletions build/cmake/SqliteOrmConfig.cmake.in

This file was deleted.

Loading

0 comments on commit 4c6a46b

Please sign in to comment.