Skip to content

Commit fbaa832

Browse files
author
Simon Knopp
committed
Add ability to disable tests
The tests require C++14 although the rest of the code doesn't. Adding the ability to disable tests lets people with old compilers build the plugin.
1 parent 5f6c8c2 commit fbaa832

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ option(STATIC "Build plugin as a static library" OFF)
1717
if(STATIC)
1818
set(LIBTYPE STATIC)
1919
add_definitions(-DQT_STATICPLUGIN)
20-
add_subdirectory(test-static)
20+
set(TEST_DIR test-static)
2121
else()
2222
set(LIBTYPE MODULE)
23-
add_subdirectory(test-shared)
23+
set(TEST_DIR test-shared)
2424
endif()
2525

2626
add_library(qsqlcipher ${LIBTYPE}
@@ -38,3 +38,7 @@ target_link_libraries(qsqlcipher
3838
${SQLCIPHER_LIBRARIES}
3939
)
4040

41+
include(CTest)
42+
if(BUILD_TESTING)
43+
add_subdirectory(${TEST_DIR})
44+
endif()

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ Note that setting ``-DSTATIC=ON`` only builds *this plugin* as a static library.
4747
If you also want to link to static versions of Qt and/or SQLCipher, it's up to
4848
you to make sure CMake finds static versions of those libraries.
4949

50+
51+
## Tests
52+
53+
Some basic tests are included - run ``make test``. Note that while pretty much
54+
any C++ compiler can build the actual plugin, the tests require support for
55+
C++14. If you have an old compiler you can pass ``-DBUILD_TESTING=OFF`` to CMake
56+
to skip building the tests.
57+
5058
-----
5159

5260
## Old version

test-shared/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ set(CMAKE_CXX_FLAGS "-std=c++14")
33

44
add_executable(qsqlcipher-test main.cpp)
55
target_link_libraries(qsqlcipher-test Qt5::Sql)
6+
7+
add_test(NAME qsqlcipher-test COMMAND qsqlcipher-test)

0 commit comments

Comments
 (0)