Skip to content

Commit 4c6a46b

Browse files
authored
Merge pull request #564 from fnc12/dev
v1.6
2 parents f51a734 + 76f4d7c commit 4c6a46b

File tree

142 files changed

+11696
-6741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+11696
-6741
lines changed

.github/workflows/clang-format-lint.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ jobs:
1010
- uses: actions/checkout@v1
1111
- name: clang-format lint
1212
uses: DoozyX/clang-format-lint-action@v0.3.1
13-
with:
14-
exclude: ./include

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ examples/simple_neural_network.cpp
44
cmake-build-debug/
55

66
.idea/
7+
8+
/compile

.travis.yml

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Defaults
22
os: linux
3-
dist: xenial
3+
dist: bionic
44

55
matrix:
66
include:
@@ -38,18 +38,18 @@ matrix:
3838
env:
3939
- SQLITE_ORM_OMITS_CODECVT: ON
4040

41-
- name: "[C++14] AppleClang-10.0.1"
42-
os: osx
43-
osx_image: xcode10.2
44-
language: cpp
45-
env:
46-
- SQLITE_ORM_OMITS_CODECVT: ON
47-
addons:
48-
homebrew:
49-
packages:
50-
- catch2
51-
- ninja
52-
update: true
41+
# - name: "[C++14] AppleClang-10.0.1"
42+
# os: osx
43+
# osx_image: xcode10.2
44+
# language: cpp
45+
# env:
46+
# - SQLITE_ORM_OMITS_CODECVT: ON
47+
# addons:
48+
# homebrew:
49+
# packages:
50+
# - catch2
51+
# - ninja
52+
# update: true
5353

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

74-
- name: "[C++14] GCC-6"
75-
os: osx
76-
osx_image: xcode10.2
77-
addons:
78-
homebrew:
79-
packages:
80-
- gcc@6
81-
- catch2
82-
- ninja
83-
update: true
84-
env:
85-
- CC: gcc-6
86-
- CXX: g++-6
74+
# - name: "[C++14] GCC-6"
75+
# os: osx
76+
# osx_image: xcode10.2
77+
# addons:
78+
# homebrew:
79+
# packages:
80+
# - gcc@6
81+
# - catch2
82+
# - ninja
83+
# update: true
84+
# env:
85+
# - CC: gcc-6
86+
# - CXX: g++-6
8787

8888
- name: "[C++17] GCC-9"
8989
addons:
@@ -111,19 +111,19 @@ matrix:
111111
- CXX: g++-7
112112
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
113113

114-
- name: "[C++17] AppleClang-10.0.1"
115-
os: osx
116-
osx_image: xcode10.2
117-
language: cpp
118-
env:
119-
- SQLITE_ORM_OMITS_CODECVT: ON
120-
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
121-
addons:
122-
homebrew:
123-
packages:
124-
- catch2
125-
- ninja
126-
update: true
114+
# - name: "[C++17] AppleClang-10.0.1"
115+
# os: osx
116+
# osx_image: xcode10.2
117+
# language: cpp
118+
# env:
119+
# - SQLITE_ORM_OMITS_CODECVT: ON
120+
# - SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
121+
# addons:
122+
# homebrew:
123+
# packages:
124+
# - catch2
125+
# - ninja
126+
# update: true
127127

128128
# - name: "[C++17] LLVM/Clang (latest)"
129129
# os: osx
@@ -151,16 +151,12 @@ before_install:
151151
if [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
152152
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" # Use coreutils from homebrew.
153153
fi
154-
155-
install:
156-
- |
157-
# Catch2 test framework
158-
if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
159-
git clone --depth=1 --quiet https://github.com/catchorg/Catch2.git
160-
cd Catch2
161-
cmake -Bbuild -H. -DBUILD_TESTING=OFF
162-
sudo env "PATH=$PATH" cmake --build ./build --target install
163-
fi
154+
# Add ppa repo for cmake and delete cmake 3.12.4 folder of travis
155+
- 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
156+
- sudo apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main'
157+
- sudo apt-get update -qq -y
158+
- sudo apt-get install -y cmake
159+
- sudo rm -r /usr/local/cmake-3.12.4/
164160

165161
# scripts to run before build
166162
before_script:

CMakeLists.txt

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
cmake_minimum_required (VERSION 3.2)
2-
cmake_policy(SET CMP0057 NEW)
1+
cmake_minimum_required (VERSION 3.16.0)
32

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

2423
project("sqlite_orm" VERSION ${PACKAGE_VERSION})
2524

25+
2626
set(CMAKE_VERBOSE_MAKEFILE ON)
2727

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

30-
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
31-
32-
# Build time options are defined here
33-
include(DefineInstallationPaths)
34-
35-
# Generate the SqliteOrmConfig.cmake module
36-
include(GenerateConfigModule)
30+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
3731

38-
set(ProjectName "SqliteOrm")
32+
include(CTest)
3933

40-
option(SqliteOrm_BuildTests "Build sqlite_orm unit tests" ON)
34+
### Dependencies
35+
add_subdirectory(dependencies)
4136

37+
### Main Build Targets
4238
set(SqliteOrm_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include")
4339
add_library(sqlite_orm INTERFACE)
40+
add_library(sqlite_orm::sqlite_orm ALIAS sqlite_orm)
41+
42+
find_package(SQLite3 REQUIRED)
43+
target_link_libraries(sqlite_orm INTERFACE SQLite::SQLite3)
4444

45-
target_sources(sqlite_orm INTERFACE
46-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/sqlite_orm/sqlite_orm.h>
47-
$<INSTALL_INTERFACE:include/sqlite_orm/sqlite_orm.h>)
45+
target_sources(sqlite_orm INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/sqlite_orm/sqlite_orm.h>)
4846

49-
target_include_directories(sqlite_orm INTERFACE
50-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
51-
$<INSTALL_INTERFACE:include>)
47+
target_include_directories(sqlite_orm INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
5248

5349
include(ucm)
5450

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

7167
# Tests
72-
include(CTest)
73-
if(SqliteOrm_BuildTests AND BUILD_TESTING)
74-
enable_testing()
68+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
7569
add_subdirectory(tests)
7670
endif()
7771

78-
add_subdirectory(examples)
79-
80-
install(TARGETS sqlite_orm EXPORT "${ProjectName}Targets"
81-
INCLUDES DESTINATION "${INCLUDE_INSTALL_DIR}" COMPONENT Development
82-
PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}" COMPONENT Development)
83-
84-
install(FILES "include/sqlite_orm/sqlite_orm.h"
85-
DESTINATION "${INCLUDE_INSTALL_DIR}" COMPONENT Development)
86-
87-
export(EXPORT "${ProjectName}Targets"
88-
FILE "${CMAKE_CURRENT_BINARY_DIR}/${ProjectName}/${ProjectName}Targets.cmake"
89-
NAMESPACE "sqlite_orm::")
72+
option(BUILD_EXAMPLES ON)
73+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_EXAMPLES)
74+
add_subdirectory(examples)
75+
endif()
9076

91-
install(EXPORT "${ProjectName}Targets"
92-
FILE "${ProjectName}Targets.cmake"
93-
NAMESPACE "sqlite_orm::"
94-
DESTINATION "${CMAKE_INSTALL_DIR}/sqlite_orm")
77+
### Packaging
78+
add_subdirectory(packaging)

README.md

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ SQLite ORM light header only library for modern C++
4242
* **Easy integration** - single header only lib.
4343
* **The only dependency** - libsqlite3
4444
* **C++ standard code style**
45-
* **No undefined behaviour** - if something goes wrong lib throws an exception
4645
* **In memory database support** - provide `:memory:` or empty filename
4746
* **COLLATE support**
4847
* **Limits setting/getting support**
@@ -754,31 +753,56 @@ For more details please check the project [wiki](https://github.com/fnc12/sqlite
754753

755754
# Installation
756755

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

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

761762
```bash
762763
git clone https://github.com/fnc12/sqlite_orm.git sqlite_orm
763764
cd sqlite_orm
764-
mkdir compile
765-
cd compile
766-
cmake ..
767-
cmake --build .
768-
sudo make install
765+
cmake -B build
766+
cmake --build build --target install
769767
```
768+
You might need admin rights for the last command.
769+
770+
# Usage
771+
772+
## CMake
773+
774+
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).
770775

771-
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
776+
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)
777+
778+
## Find Package
779+
780+
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.
772781

773782
```cmake
774-
find_package(sqlite_orm CONFIG REQUIRED)
783+
find_package(SqliteOrm REQUIRED)
784+
775785
target_link_libraries(main PRIVATE sqlite_orm::sqlite_orm)
776-
target_include_directories(main PRIVATE ${SQLITE_ORM_INCLUDE_DIR})
777786
```
778787

779-
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.
788+
## Fetch Content (Recommended)
789+
790+
Alternatively, cmake can download the project directly from github during configure stage and therefore you don't need to install the lib before.
791+
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.
792+
793+
## No CMake
794+
795+
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.
780796

781797
# Requirements
782798

783799
* C++14 compatible compiler (not C++11 cause of templated lambdas in the lib).
784-
* libsqlite3 linked to your binary
800+
* 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)
801+
802+
# Video from conference
803+
804+
[![Video from conference](https://img.youtube.com/vi/ngsilquWgpo/0.jpg)](https://www.youtube.com/watch?v=ngsilquWgpo)
805+
806+
# SqliteMan
807+
808+
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.

TODO.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

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

5-
* `FOREIGN KEY` - sync_schema fk comparison and ability of two tables to have fk to each other
5+
* `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)
66
* rest of core functions(https://sqlite.org/lang_corefunc.html)
77
* `ATTACH`
88
* blob incremental I/O https://sqlite.org/c3ref/blob_open.html
9-
* reusing of prepared statements - useful for query optimisation
109
* explicit FROM for subqueries in FROM argument
11-
* backup API https://www.sqlite.org/backup.html
12-
* busy handler https://sqlite.org/c3ref/busy_handler.html
1310
* CREATE VIEW and other view operations https://sqlite.org/lang_createview.html
1411
* triggers
1512
* query static check for correct order (e.g. `GROUP BY` after `WHERE`)
1613
* `WINDOW`
1714
* `UPSERT` https://www.sqlite.org/lang_UPSERT.html
18-
* `CHECK` constraint
1915
* `SAVEPOINT` https://www.sqlite.org/lang_savepoint.html
16+
* 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)
17+
* generated columns https://www.sqlite.org/gencol.html
18+
* named constraints: constraint can have name `CREATE TABLE heroes(id INTEGER CONSTRAINT pk PRIMARY KEY)`
2019

2120
Please feel free to add any feature that isn't listed here and not implemented yet.

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ init:
4444

4545
install:
4646
- C:\Tools\vcpkg\vcpkg integrate install
47-
- vcpkg install catch2:%PLATFORM%-windows
47+
- vcpkg install sqlite3:%PLATFORM%-windows
4848

4949
# scripts to run before build
5050
before_build:

build/cmake/DefineInstallationPaths.cmake

Lines changed: 0 additions & 12 deletions
This file was deleted.

build/cmake/GenerateConfigModule.cmake

Lines changed: 0 additions & 24 deletions
This file was deleted.

build/cmake/SqliteOrmConfig.cmake.in

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)