From be6a77eb7457f08c326029d15949558013c8e2db Mon Sep 17 00:00:00 2001 From: silverqx Date: Fri, 6 May 2022 17:27:52 +0200 Subject: [PATCH] docs, unified Consume TinyOrm library (qmake) [skip ci] --- docs/building-tinyorm.mdx | 99 +++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 52 deletions(-) diff --git a/docs/building-tinyorm.mdx b/docs/building-tinyorm.mdx index 264739735..3f96f08da 100644 --- a/docs/building-tinyorm.mdx +++ b/docs/building-tinyorm.mdx @@ -595,46 +595,17 @@ Important `qmake` options. ### Consume TinyOrm library (qmake) {#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() +# 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. @@ -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() 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/) ``` @@ -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() 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/) ``` +The last thing is to set up the `INCLUDEPATH` for the `vcpkg` that provides the `range-v3` and `tabulate` header files. + + + + +```qmake +# vcpkg - range-v3 and tabulate +# --- +INCLUDEPATH += $$quote(/vcpkg/installed/x64-windows/include/) +``` + + + + +```qmake +# vcpkg - range-v3 and tabulate +# --- +QMAKE_CXXFLAGS += -isystem $$shell_quote(/vcpkg/installed/x64-linux/include/) +``` + + + + +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. + + + + +{`$env:Path = "${applicationFolderPath(pwsh, false)}\\TinyORM\\TinyORM-builds-qmake\\build-debug;" + $env:Path`} + + + + +{`export LD_LIBRARY_PATH=${applicationFolderPath(bash)}/TinyORM/TinyORM-builds-qmake/build-debug\${PATH:+:}$PATH`} + + + + :::tip On Linux `-isystem` marks the directory as a system directory, it prevents warnings. :::