|
1 | | -#(!) this CMake build system IS experimental and is made mostly for using CLion IDE. |
2 | | -# Scons - is the main RCDB make system, so please use it in order to build rcdb.lib and examples |
| 1 | +# RCDB C++ is a header-only library - nothing here is required to USE it (just #include the headers |
| 2 | +# and link sqlite3 and/or the mysql client). This CMake project builds the unit tests and examples. |
| 3 | +# |
| 4 | +# Build & run the SQLite unit tests: |
| 5 | +# cmake -S . -B build -DWITH_SQLITE=ON -DWITH_MYSQL=OFF |
| 6 | +# cmake --build build --target test_rcdb_cpp |
| 7 | +# RCDB_TEST_CONNECTION="sqlite:///<path-to>.sqlite" ./build/test_rcdb_cpp |
| 8 | +# Create the test database with: rcdb -c sqlite:///<path-to>.sqlite db init --add-cpp-tests --confirm |
3 | 9 |
|
4 | 10 | cmake_minimum_required(VERSION 3.4) |
5 | 11 | project(rcdb_cpp) |
@@ -68,17 +74,27 @@ SET(TEST_SOURCE_FILES |
68 | 74 | include/RCDB/StringUtils.h |
69 | 75 | include/RCDB/ConfigParser.h |
70 | 76 |
|
71 | | - tests/test_Connection.cpp |
72 | 77 | tests/test_ConditionType.cpp |
73 | | - tests/test_MySqlProvider.cpp |
74 | | - tests/test_SqLiteProvider.cpp |
75 | 78 |
|
76 | 79 | tests/catch.hpp |
77 | 80 | tests/catch.cpp |
78 | 81 | tests/test_ConfigParser.cpp |
79 | 82 | include/json/json.hpp |
80 | 83 | ) |
81 | 84 |
|
| 85 | +# Provider tests are gated by the corresponding DB backend, so an SQLite-only |
| 86 | +# build does not need MySQL headers (mysql.h) and a MySQL-only build does not need SQLite. |
| 87 | +if(WITH_MYSQL) |
| 88 | + list(APPEND TEST_SOURCE_FILES tests/test_MySqlProvider.cpp) |
| 89 | +endif() |
| 90 | + |
| 91 | +# The Connection and SqLiteProvider tests both pull in the SQLiteCpp amalgamation, |
| 92 | +# whose out-of-line definitions are not `inline`. Compile them as a single unity |
| 93 | +# translation unit (tests/test_sqlite_unity.cpp) so the definitions appear once. |
| 94 | +if(WITH_SQLITE) |
| 95 | + list(APPEND TEST_SOURCE_FILES tests/test_sqlite_unity.cpp) |
| 96 | +endif() |
| 97 | + |
82 | 98 | add_executable(test_rcdb_cpp ${TEST_SOURCE_FILES}) |
83 | 99 | add_executable(examples_trigger_params examples/get_trigger_params.cpp) |
84 | 100 | add_executable(examples_fadc_masks examples/get_fadc_masks.cpp) |
|
0 commit comments