docs, unified Consume TinyOrm library (qmake)

[skip ci]
This commit is contained in:
silverqx
2022-05-06 17:27:52 +02:00
parent 2a43df8afe
commit be6a77eb74
+47 -52
View File
@@ -595,46 +595,17 @@ Important `qmake` options.
### Consume TinyOrm library <small>(qmake)</small> {#consume-tinyorm-library-qmake}
A basic [`TinyOrm.pri`](https://github.com/silverqx/TinyORM/blob/main/qmake/TinyOrm.pri) file is available to simplify the integration of the `TinyORM` library into your application. This file sets up basic qmake variables that are needed by `TinyORM`. You can use it to configure the `TinyORM` library.
The [`TinyOrm.pri`](https://github.com/silverqx/TinyORM/blob/main/qmake/TinyOrm.pri) file is available to simplify the integration of the `TinyORM` library into your application. This file sets up all the qmake variables that are needed by `TinyORM`. You can use it to configure the `TinyORM` library.
```qmake
include($$PWD/../../TinyORM/TinyORM/qmake/TinyOrm.pri)
TINY_MAIN_DIR = $$clean_path(<your_path>)
# Name of this qmake variable is crucial
TINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyOrm-builds-qmake/build-TinyOrm-Desktop_Qt_6_2_4_MSVC2019_64bit-Debug)
include($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)
```
Or you can configure `TinyORM` library manually.
```qmake
# TinyORM configuration
# ---
CONFIG *= c++2a strict_c++ warn_on utf8_source link_prl hide_symbols silent
# TinyORM defines
# ---
# Link against the shared library
CONFIG(shared, dll|shared|static|staticlib) | \
CONFIG(dll, dll|shared|static|staticlib): \
DEFINES *= TINYORM_LINKING_SHARED
# Release build
CONFIG(release, debug|release): \
DEFINES *= TINYORM_NO_DEBUG
# Log queries with a time measurement in debug build
CONFIG(release, debug|release): \
DEFINES *= TINYORM_NO_DEBUG_SQL
# TinyTom defines
# ---
# Release build
CONFIG(release, debug|release): DEFINES += TINYTOM_NO_DEBUG
# Debug build
CONFIG(debug, debug|release): DEFINES *= TINYTOM_DEBUG
```
And of course you have to set the `INCLUDEPATH` and `LIBS`.
You will have to link against the `TinyORM` library manually if you don't set the `TINYORM_BUILD_TREE` qmake variable before the inclusion of the `TinyOrm.pri` file. The `INCLUDEPATH` is autodetected every time.
<Tabs groupId={shell}>
<TabItem value={pwsh} label={pwsh_label}>
@@ -642,22 +613,15 @@ And of course you have to set the `INCLUDEPATH` and `LIBS`.
```qmake
# Link against TinyORM library
# ---
TINY_MAIN_DIR = $$quote($$PWD/../../TinyORM)
TINY_MAIN_DIR = $$clean_path(<your_path>)
TINY_TINYORM_BUILDS_DIR = $$quote($$TINY_MAIN_DIR/TinyOrm-builds-qmake)
# Configure TinyORM library
include($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)
# TinyORM header files
INCLUDEPATH += $$quote($$TINY_MAIN_DIR/TinyORM/include/)
# TinyORM library path
LIBS += $$quote(-L$$TINY_TINYORM_BUILDS_DIR/build-TinyOrm-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/src/debug/)
LIBS += -lTinyOrm
# vcpkg - range-v3 and tabulate
# ---
INCLUDEPATH += $$quote(../../../../vcpkg/installed/x64-windows/include/)
```
</TabItem>
@@ -666,27 +630,58 @@ INCLUDEPATH += $$quote(../../../../vcpkg/installed/x64-windows/include/)
```qmake
# Link against TinyORM library
# ---
TINY_MAIN_DIR = $$quote($$PWD/../../TinyORM)
TINY_MAIN_DIR = $$clean_path(<your_path>)
TINY_TINYORM_BUILDS_DIR = $$quote($$TINY_MAIN_DIR/TinyOrm-builds-qmake)
# Configure TinyORM library
include($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)
# TinyORM header files
QMAKE_CXXFLAGS += -isystem $$shell_quote($$TINY_MAIN_DIR/TinyORM/include/)
# TinyORM library path
LIBS += $$quote(-L$$TINY_TINYORM_BUILDS_DIR/build-TinyOrm-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/debug/)
LIBS += -lTinyOrm
# vcpkg - range-v3 and tabulate
# ---
QMAKE_CXXFLAGS += -isystem $$shell_quote(../../../../vcpkg/installed/x64-linux/include/)
```
</TabItem>
</Tabs>
The last thing is to set up the `INCLUDEPATH` for the `vcpkg` that provides the `range-v3` and `tabulate` header files.
<Tabs groupId={shell}>
<TabItem value={pwsh} label={pwsh_label}>
```qmake
# vcpkg - range-v3 and tabulate
# ---
INCLUDEPATH += $$quote(<your_path>/vcpkg/installed/x64-windows/include/)
```
</TabItem>
<TabItem value={bash} label={bash_label}>
```qmake
# vcpkg - range-v3 and tabulate
# ---
QMAKE_CXXFLAGS += -isystem $$shell_quote(<your_path>/vcpkg/installed/x64-linux/include/)
```
</TabItem>
</Tabs>
Do not forget to add `TinyOrm0d.dll` on the path on Windows and on the `LD_LIBRARY_PATH` on Linux, so your application can find it during execution.
<Tabs groupId={shell} name='tinyorm-on-path'>
<TabItem value={pwsh} label={pwsh_label}>
<CodeBlock className='language-powershell'>
{`$env:Path = "${applicationFolderPath(pwsh, false)}\\TinyORM\\TinyORM-builds-qmake\\build-debug;" + $env:Path`}
</CodeBlock>
</TabItem>
<TabItem value={bash} label={bash_label}>
<CodeBlock className='language-bash'>
{`export LD_LIBRARY_PATH=${applicationFolderPath(bash)}/TinyORM/TinyORM-builds-qmake/build-debug\${PATH:+:}$PATH`}
</CodeBlock>
</TabItem>
</Tabs>
:::tip
On Linux `-isystem` marks the directory as a system directory, it prevents warnings.
:::